From da20e8dcd2867df0a9a6ebc1081edb2db2eebdef Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 29 Oct 2016 16:02:21 -0400 Subject: continue with .net core targeting --- MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs') diff --git a/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs b/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs index fca9e763f..875575daf 100644 --- a/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs +++ b/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs @@ -68,15 +68,11 @@ namespace MediaBrowser.Server.Implementations.Sync { _logger.Debug("Getting {0} from {1}", string.Join(MediaSync.PathSeparatorString, GetRemotePath().ToArray()), _provider.Name); - var fileResult = await _provider.GetFiles(new FileQuery - { - FullPath = GetRemotePath().ToArray() - - }, _target, cancellationToken).ConfigureAwait(false); + var fileResult = await _provider.GetFiles(GetRemotePath().ToArray(), _target, cancellationToken).ConfigureAwait(false); if (fileResult.Items.Length > 0) { - using (var stream = await _provider.GetFile(fileResult.Items[0].Id, _target, new Progress(), cancellationToken)) + using (var stream = await _provider.GetFile(fileResult.Items[0].FullName, _target, new Progress(), cancellationToken)) { return _json.DeserializeFromStream>(stream); } -- cgit v1.2.3 From 1f5addfbb7bde693ec2c785e233d99635604f638 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 29 Oct 2016 16:13:23 -0400 Subject: move dependencies --- Emby.Common.Implementations/Logging/NLogger.cs | 224 +++++++++++++++++ Emby.Common.Implementations/Logging/NlogManager.cs | 264 +++++++++++++++++++++ .../EntryPoints/ActivityLogEntryPoint.cs | 1 - .../Library/LibraryManager.cs | 3 +- .../Library/Resolvers/Movies/MovieResolver.cs | 3 +- .../Logging/NLogger.cs | 224 ----------------- .../Logging/NlogManager.cs | 264 --------------------- .../MediaBrowser.Server.Implementations.csproj | 11 +- .../Sync/MediaSync.cs | 1 - .../Sync/TargetDataProvider.cs | 5 - .../packages.config | 4 +- MediaBrowser.Server.Mono/Program.cs | 2 +- .../ApplicationHost.cs | 1 - .../UnhandledExceptionWriter.cs | 1 - MediaBrowser.ServerApplication/MainStartup.cs | 4 +- 15 files changed, 495 insertions(+), 517 deletions(-) create mode 100644 Emby.Common.Implementations/Logging/NLogger.cs create mode 100644 Emby.Common.Implementations/Logging/NlogManager.cs delete mode 100644 MediaBrowser.Server.Implementations/Logging/NLogger.cs delete mode 100644 MediaBrowser.Server.Implementations/Logging/NlogManager.cs (limited to 'MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs') diff --git a/Emby.Common.Implementations/Logging/NLogger.cs b/Emby.Common.Implementations/Logging/NLogger.cs new file mode 100644 index 000000000..8abd3d0d9 --- /dev/null +++ b/Emby.Common.Implementations/Logging/NLogger.cs @@ -0,0 +1,224 @@ +using MediaBrowser.Model.Logging; +using System; +using System.Text; + +namespace Emby.Common.Implementations.Logging +{ + /// + /// Class NLogger + /// + public class NLogger : ILogger + { + /// + /// The _logger + /// + private readonly NLog.Logger _logger; + + private readonly ILogManager _logManager; + + /// + /// The _lock object + /// + private static readonly object LockObject = new object(); + + /// + /// Initializes a new instance of the class. + /// + /// The name. + /// The log manager. + public NLogger(string name, ILogManager logManager) + { + _logManager = logManager; + lock (LockObject) + { + _logger = NLog.LogManager.GetLogger(name); + } + } + + /// + /// Infoes the specified message. + /// + /// The message. + /// The param list. + public void Info(string message, params object[] paramList) + { + _logger.Info(message, paramList); + } + + /// + /// Errors the specified message. + /// + /// The message. + /// The param list. + public void Error(string message, params object[] paramList) + { + _logger.Error(message, paramList); + } + + /// + /// Warns the specified message. + /// + /// The message. + /// The param list. + public void Warn(string message, params object[] paramList) + { + _logger.Warn(message, paramList); + } + + /// + /// Debugs the specified message. + /// + /// The message. + /// The param list. + public void Debug(string message, params object[] paramList) + { + if (_logManager.LogSeverity == LogSeverity.Info) + { + return; + } + + _logger.Debug(message, paramList); + } + + /// + /// Logs the exception. + /// + /// The message. + /// The exception. + /// The param list. + /// + public void ErrorException(string message, Exception exception, params object[] paramList) + { + LogException(LogSeverity.Error, message, exception, paramList); + } + + /// + /// Logs the exception. + /// + /// The level. + /// The message. + /// The exception. + /// The param list. + private void LogException(LogSeverity level, string message, Exception exception, params object[] paramList) + { + message = FormatMessage(message, paramList).Replace(Environment.NewLine, ". "); + + var messageText = LogHelper.GetLogMessage(exception); + + var prefix = _logManager.ExceptionMessagePrefix; + + if (!string.IsNullOrWhiteSpace(prefix)) + { + messageText.Insert(0, prefix); + } + + LogMultiline(message, level, messageText); + } + + /// + /// Formats the message. + /// + /// The message. + /// The param list. + /// System.String. + private static string FormatMessage(string message, params object[] paramList) + { + if (paramList != null) + { + for (var i = 0; i < paramList.Length; i++) + { + var obj = paramList[i]; + + message = message.Replace("{" + i + "}", (obj == null ? "null" : obj.ToString())); + } + } + + return message; + } + + /// + /// Logs the multiline. + /// + /// The message. + /// The severity. + /// Content of the additional. + public void LogMultiline(string message, LogSeverity severity, StringBuilder additionalContent) + { + if (severity == LogSeverity.Debug && _logManager.LogSeverity == LogSeverity.Info) + { + return; + } + + additionalContent.Insert(0, message + Environment.NewLine); + + const char tabChar = '\t'; + + var text = additionalContent.ToString() + .Replace(Environment.NewLine, Environment.NewLine + tabChar) + .TrimEnd(tabChar); + + if (text.EndsWith(Environment.NewLine)) + { + text = text.Substring(0, text.LastIndexOf(Environment.NewLine, StringComparison.OrdinalIgnoreCase)); + } + + _logger.Log(GetLogLevel(severity), text); + } + + /// + /// Gets the log level. + /// + /// The severity. + /// NLog.LogLevel. + private NLog.LogLevel GetLogLevel(LogSeverity severity) + { + switch (severity) + { + case LogSeverity.Debug: + return NLog.LogLevel.Debug; + case LogSeverity.Error: + return NLog.LogLevel.Error; + case LogSeverity.Warn: + return NLog.LogLevel.Warn; + case LogSeverity.Fatal: + return NLog.LogLevel.Fatal; + case LogSeverity.Info: + return NLog.LogLevel.Info; + default: + throw new ArgumentException("Unknown LogSeverity: " + severity.ToString()); + } + } + + /// + /// Logs the specified severity. + /// + /// The severity. + /// The message. + /// The param list. + public void Log(LogSeverity severity, string message, params object[] paramList) + { + _logger.Log(GetLogLevel(severity), message, paramList); + } + + /// + /// Fatals the specified message. + /// + /// The message. + /// The param list. + public void Fatal(string message, params object[] paramList) + { + _logger.Fatal(message, paramList); + } + + /// + /// Fatals the exception. + /// + /// The message. + /// The exception. + /// The param list. + public void FatalException(string message, Exception exception, params object[] paramList) + { + LogException(LogSeverity.Fatal, message, exception, paramList); + } + } +} diff --git a/Emby.Common.Implementations/Logging/NlogManager.cs b/Emby.Common.Implementations/Logging/NlogManager.cs new file mode 100644 index 000000000..e38b87bd1 --- /dev/null +++ b/Emby.Common.Implementations/Logging/NlogManager.cs @@ -0,0 +1,264 @@ +using System; +using System.IO; +using System.Linq; +using NLog; +using NLog.Config; +using NLog.Targets; +using NLog.Targets.Wrappers; +using MediaBrowser.Model.Logging; + +namespace Emby.Common.Implementations.Logging +{ + /// + /// Class NlogManager + /// + public class NlogManager : ILogManager + { + /// + /// Occurs when [logger loaded]. + /// + public event EventHandler LoggerLoaded; + /// + /// Gets or sets the log directory. + /// + /// The log directory. + private string LogDirectory { get; set; } + /// + /// Gets or sets the log file prefix. + /// + /// The log file prefix. + private string LogFilePrefix { get; set; } + /// + /// Gets the log file path. + /// + /// The log file path. + public string LogFilePath { get; private set; } + + /// + /// Gets or sets the exception message prefix. + /// + /// The exception message prefix. + public string ExceptionMessagePrefix { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// The log directory. + /// The log file name prefix. + public NlogManager(string logDirectory, string logFileNamePrefix) + { + LogDirectory = logDirectory; + LogFilePrefix = logFileNamePrefix; + + LogManager.Configuration = new LoggingConfiguration (); + } + + private LogSeverity _severity = LogSeverity.Debug; + public LogSeverity LogSeverity + { + get + { + return _severity; + } + set + { + var changed = _severity != value; + + _severity = value; + + if (changed) + { + UpdateLogLevel(value); + } + } + } + + private void UpdateLogLevel(LogSeverity newLevel) + { + var level = GetLogLevel(newLevel); + + var rules = LogManager.Configuration.LoggingRules; + + foreach (var rule in rules) + { + if (!rule.IsLoggingEnabledForLevel(level)) + { + rule.EnableLoggingForLevel(level); + } + foreach (var lev in rule.Levels.ToArray()) + { + if (lev < level) + { + rule.DisableLoggingForLevel(lev); + } + } + } + } + + /// + /// Adds the file target. + /// + /// The path. + /// The level. + private void AddFileTarget(string path, LogSeverity level) + { + RemoveTarget("ApplicationLogFileWrapper"); + + var wrapper = new AsyncTargetWrapper (); + wrapper.Name = "ApplicationLogFileWrapper"; + + var logFile = new FileTarget + { + FileName = path, + Layout = "${longdate} ${level} ${logger}: ${message}" + }; + + logFile.Name = "ApplicationLogFile"; + + wrapper.WrappedTarget = logFile; + + AddLogTarget(wrapper, level); + } + + /// + /// Adds the log target. + /// + /// The target. + /// The level. + public void AddLogTarget(Target target, LogSeverity level) + { + var config = LogManager.Configuration; + config.AddTarget(target.Name, target); + + var rule = new LoggingRule("*", GetLogLevel(level), target); + config.LoggingRules.Add(rule); + + LogManager.Configuration = config; + } + + /// + /// Removes the target. + /// + /// The name. + public void RemoveTarget(string name) + { + var config = LogManager.Configuration; + + var target = config.FindTargetByName(name); + + if (target != null) + { + foreach (var rule in config.LoggingRules.ToList()) + { + var contains = rule.Targets.Contains(target); + + rule.Targets.Remove(target); + + if (contains) + { + config.LoggingRules.Remove(rule); + } + } + + config.RemoveTarget(name); + LogManager.Configuration = config; + } + } + + /// + /// Gets the logger. + /// + /// The name. + /// ILogger. + public MediaBrowser.Model.Logging.ILogger GetLogger(string name) + { + return new NLogger(name, this); + } + + /// + /// Gets the log level. + /// + /// The severity. + /// LogLevel. + /// Unrecognized LogSeverity + private LogLevel GetLogLevel(LogSeverity severity) + { + switch (severity) + { + case LogSeverity.Debug: + return LogLevel.Debug; + case LogSeverity.Error: + return LogLevel.Error; + case LogSeverity.Fatal: + return LogLevel.Fatal; + case LogSeverity.Info: + return LogLevel.Info; + case LogSeverity.Warn: + return LogLevel.Warn; + default: + throw new ArgumentException("Unrecognized LogSeverity"); + } + } + + /// + /// Reloads the logger. + /// + /// The level. + public void ReloadLogger(LogSeverity level) + { + LogFilePath = Path.Combine(LogDirectory, LogFilePrefix + "-" + decimal.Floor(DateTime.Now.Ticks / 10000000) + ".txt"); + + Directory.CreateDirectory(Path.GetDirectoryName(LogFilePath)); + + AddFileTarget(LogFilePath, level); + + LogSeverity = level; + + if (LoggerLoaded != null) + { + try + { + LoggerLoaded(this, EventArgs.Empty); + } + catch (Exception ex) + { + GetLogger("Logger").ErrorException("Error in LoggerLoaded event", ex); + } + } + } + + /// + /// Flushes this instance. + /// + public void Flush() + { + LogManager.Flush(); + } + + + public void AddConsoleOutput() + { + RemoveTarget("ConsoleTargetWrapper"); + + var wrapper = new AsyncTargetWrapper (); + wrapper.Name = "ConsoleTargetWrapper"; + + var target = new ConsoleTarget() + { + Layout = "${level}, ${logger}, ${message}", + Error = false + }; + + target.Name = "ConsoleTarget"; + + wrapper.WrappedTarget = target; + + AddLogTarget(wrapper, LogSeverity); + } + + public void RemoveConsoleOutput() + { + RemoveTarget("ConsoleTargetWrapper"); + } + } +} diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs index 431bd3327..96b8aad5d 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Updates; using MediaBrowser.Controller; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index e9e4f7148..18feaa849 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1,5 +1,4 @@ -using Interfaces.IO; -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index cfbc962d4..bb1d57688 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -1,5 +1,4 @@ -using Interfaces.IO; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; diff --git a/MediaBrowser.Server.Implementations/Logging/NLogger.cs b/MediaBrowser.Server.Implementations/Logging/NLogger.cs deleted file mode 100644 index 11f41261a..000000000 --- a/MediaBrowser.Server.Implementations/Logging/NLogger.cs +++ /dev/null @@ -1,224 +0,0 @@ -using MediaBrowser.Model.Logging; -using System; -using System.Text; - -namespace MediaBrowser.Common.Implementations.Logging -{ - /// - /// Class NLogger - /// - public class NLogger : ILogger - { - /// - /// The _logger - /// - private readonly NLog.Logger _logger; - - private readonly ILogManager _logManager; - - /// - /// The _lock object - /// - private static readonly object LockObject = new object(); - - /// - /// Initializes a new instance of the class. - /// - /// The name. - /// The log manager. - public NLogger(string name, ILogManager logManager) - { - _logManager = logManager; - lock (LockObject) - { - _logger = NLog.LogManager.GetLogger(name); - } - } - - /// - /// Infoes the specified message. - /// - /// The message. - /// The param list. - public void Info(string message, params object[] paramList) - { - _logger.Info(message, paramList); - } - - /// - /// Errors the specified message. - /// - /// The message. - /// The param list. - public void Error(string message, params object[] paramList) - { - _logger.Error(message, paramList); - } - - /// - /// Warns the specified message. - /// - /// The message. - /// The param list. - public void Warn(string message, params object[] paramList) - { - _logger.Warn(message, paramList); - } - - /// - /// Debugs the specified message. - /// - /// The message. - /// The param list. - public void Debug(string message, params object[] paramList) - { - if (_logManager.LogSeverity == LogSeverity.Info) - { - return; - } - - _logger.Debug(message, paramList); - } - - /// - /// Logs the exception. - /// - /// The message. - /// The exception. - /// The param list. - /// - public void ErrorException(string message, Exception exception, params object[] paramList) - { - LogException(LogSeverity.Error, message, exception, paramList); - } - - /// - /// Logs the exception. - /// - /// The level. - /// The message. - /// The exception. - /// The param list. - private void LogException(LogSeverity level, string message, Exception exception, params object[] paramList) - { - message = FormatMessage(message, paramList).Replace(Environment.NewLine, ". "); - - var messageText = LogHelper.GetLogMessage(exception); - - var prefix = _logManager.ExceptionMessagePrefix; - - if (!string.IsNullOrWhiteSpace(prefix)) - { - messageText.Insert(0, prefix); - } - - LogMultiline(message, level, messageText); - } - - /// - /// Formats the message. - /// - /// The message. - /// The param list. - /// System.String. - private static string FormatMessage(string message, params object[] paramList) - { - if (paramList != null) - { - for (var i = 0; i < paramList.Length; i++) - { - var obj = paramList[i]; - - message = message.Replace("{" + i + "}", (obj == null ? "null" : obj.ToString())); - } - } - - return message; - } - - /// - /// Logs the multiline. - /// - /// The message. - /// The severity. - /// Content of the additional. - public void LogMultiline(string message, LogSeverity severity, StringBuilder additionalContent) - { - if (severity == LogSeverity.Debug && _logManager.LogSeverity == LogSeverity.Info) - { - return; - } - - additionalContent.Insert(0, message + Environment.NewLine); - - const char tabChar = '\t'; - - var text = additionalContent.ToString() - .Replace(Environment.NewLine, Environment.NewLine + tabChar) - .TrimEnd(tabChar); - - if (text.EndsWith(Environment.NewLine)) - { - text = text.Substring(0, text.LastIndexOf(Environment.NewLine, StringComparison.OrdinalIgnoreCase)); - } - - _logger.Log(GetLogLevel(severity), text); - } - - /// - /// Gets the log level. - /// - /// The severity. - /// NLog.LogLevel. - private NLog.LogLevel GetLogLevel(LogSeverity severity) - { - switch (severity) - { - case LogSeverity.Debug: - return NLog.LogLevel.Debug; - case LogSeverity.Error: - return NLog.LogLevel.Error; - case LogSeverity.Warn: - return NLog.LogLevel.Warn; - case LogSeverity.Fatal: - return NLog.LogLevel.Fatal; - case LogSeverity.Info: - return NLog.LogLevel.Info; - default: - throw new ArgumentException("Unknown LogSeverity: " + severity.ToString()); - } - } - - /// - /// Logs the specified severity. - /// - /// The severity. - /// The message. - /// The param list. - public void Log(LogSeverity severity, string message, params object[] paramList) - { - _logger.Log(GetLogLevel(severity), message, paramList); - } - - /// - /// Fatals the specified message. - /// - /// The message. - /// The param list. - public void Fatal(string message, params object[] paramList) - { - _logger.Fatal(message, paramList); - } - - /// - /// Fatals the exception. - /// - /// The message. - /// The exception. - /// The param list. - public void FatalException(string message, Exception exception, params object[] paramList) - { - LogException(LogSeverity.Fatal, message, exception, paramList); - } - } -} diff --git a/MediaBrowser.Server.Implementations/Logging/NlogManager.cs b/MediaBrowser.Server.Implementations/Logging/NlogManager.cs deleted file mode 100644 index 1bbcccd88..000000000 --- a/MediaBrowser.Server.Implementations/Logging/NlogManager.cs +++ /dev/null @@ -1,264 +0,0 @@ -using MediaBrowser.Model.Logging; -using NLog; -using NLog.Config; -using NLog.Targets; -using NLog.Targets.Wrappers; -using System; -using System.IO; -using System.Linq; - -namespace MediaBrowser.Common.Implementations.Logging -{ - /// - /// Class NlogManager - /// - public class NlogManager : ILogManager - { - /// - /// Occurs when [logger loaded]. - /// - public event EventHandler LoggerLoaded; - /// - /// Gets or sets the log directory. - /// - /// The log directory. - private string LogDirectory { get; set; } - /// - /// Gets or sets the log file prefix. - /// - /// The log file prefix. - private string LogFilePrefix { get; set; } - /// - /// Gets the log file path. - /// - /// The log file path. - public string LogFilePath { get; private set; } - - /// - /// Gets or sets the exception message prefix. - /// - /// The exception message prefix. - public string ExceptionMessagePrefix { get; set; } - - /// - /// Initializes a new instance of the class. - /// - /// The log directory. - /// The log file name prefix. - public NlogManager(string logDirectory, string logFileNamePrefix) - { - LogDirectory = logDirectory; - LogFilePrefix = logFileNamePrefix; - - LogManager.Configuration = new LoggingConfiguration (); - } - - private LogSeverity _severity = LogSeverity.Debug; - public LogSeverity LogSeverity - { - get - { - return _severity; - } - set - { - var changed = _severity != value; - - _severity = value; - - if (changed) - { - UpdateLogLevel(value); - } - } - } - - private void UpdateLogLevel(LogSeverity newLevel) - { - var level = GetLogLevel(newLevel); - - var rules = LogManager.Configuration.LoggingRules; - - foreach (var rule in rules) - { - if (!rule.IsLoggingEnabledForLevel(level)) - { - rule.EnableLoggingForLevel(level); - } - foreach (var lev in rule.Levels.ToArray()) - { - if (lev < level) - { - rule.DisableLoggingForLevel(lev); - } - } - } - } - - /// - /// Adds the file target. - /// - /// The path. - /// The level. - private void AddFileTarget(string path, LogSeverity level) - { - RemoveTarget("ApplicationLogFileWrapper"); - - var wrapper = new AsyncTargetWrapper (); - wrapper.Name = "ApplicationLogFileWrapper"; - - var logFile = new FileTarget - { - FileName = path, - Layout = "${longdate} ${level} ${logger}: ${message}" - }; - - logFile.Name = "ApplicationLogFile"; - - wrapper.WrappedTarget = logFile; - - AddLogTarget(wrapper, level); - } - - /// - /// Adds the log target. - /// - /// The target. - /// The level. - public void AddLogTarget(Target target, LogSeverity level) - { - var config = LogManager.Configuration; - config.AddTarget(target.Name, target); - - var rule = new LoggingRule("*", GetLogLevel(level), target); - config.LoggingRules.Add(rule); - - LogManager.Configuration = config; - } - - /// - /// Removes the target. - /// - /// The name. - public void RemoveTarget(string name) - { - var config = LogManager.Configuration; - - var target = config.FindTargetByName(name); - - if (target != null) - { - foreach (var rule in config.LoggingRules.ToList()) - { - var contains = rule.Targets.Contains(target); - - rule.Targets.Remove(target); - - if (contains) - { - config.LoggingRules.Remove(rule); - } - } - - config.RemoveTarget(name); - LogManager.Configuration = config; - } - } - - /// - /// Gets the logger. - /// - /// The name. - /// ILogger. - public Model.Logging.ILogger GetLogger(string name) - { - return new NLogger(name, this); - } - - /// - /// Gets the log level. - /// - /// The severity. - /// LogLevel. - /// Unrecognized LogSeverity - private LogLevel GetLogLevel(LogSeverity severity) - { - switch (severity) - { - case LogSeverity.Debug: - return LogLevel.Debug; - case LogSeverity.Error: - return LogLevel.Error; - case LogSeverity.Fatal: - return LogLevel.Fatal; - case LogSeverity.Info: - return LogLevel.Info; - case LogSeverity.Warn: - return LogLevel.Warn; - default: - throw new ArgumentException("Unrecognized LogSeverity"); - } - } - - /// - /// Reloads the logger. - /// - /// The level. - public void ReloadLogger(LogSeverity level) - { - LogFilePath = Path.Combine(LogDirectory, LogFilePrefix + "-" + decimal.Round(DateTime.Now.Ticks / 10000000) + ".txt"); - - Directory.CreateDirectory(Path.GetDirectoryName(LogFilePath)); - - AddFileTarget(LogFilePath, level); - - LogSeverity = level; - - if (LoggerLoaded != null) - { - try - { - LoggerLoaded(this, EventArgs.Empty); - } - catch (Exception ex) - { - GetLogger("Logger").ErrorException("Error in LoggerLoaded event", ex); - } - } - } - - /// - /// Flushes this instance. - /// - public void Flush() - { - LogManager.Flush(); - } - - - public void AddConsoleOutput() - { - RemoveTarget("ConsoleTargetWrapper"); - - var wrapper = new AsyncTargetWrapper (); - wrapper.Name = "ConsoleTargetWrapper"; - - var target = new ConsoleTarget() - { - Layout = "${level}, ${logger}, ${message}", - Error = false - }; - - target.Name = "ConsoleTarget"; - - wrapper.WrappedTarget = target; - - AddLogTarget(wrapper, LogSeverity); - } - - public void RemoveConsoleOutput() - { - RemoveTarget("ConsoleTargetWrapper"); - } - } -} diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 144e04a0c..a00c440b2 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -53,11 +53,8 @@ ..\packages\ini-parser.2.3.0\lib\net20\INIFileParser.dll True - - ..\packages\Interfaces.IO.1.0.0.5\lib\portable-net45+sl4+wp71+win8+wpa81\Interfaces.IO.dll - - ..\packages\MediaBrowser.Naming.1.0.0.56\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll + ..\packages\MediaBrowser.Naming.1.0.0.57\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll True @@ -67,10 +64,6 @@ ..\ThirdParty\emby\Mono.Nat.dll - - ..\packages\NLog.4.3.10\lib\net45\NLog.dll - True - ..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll @@ -278,8 +271,6 @@ - - diff --git a/MediaBrowser.Server.Implementations/Sync/MediaSync.cs b/MediaBrowser.Server.Implementations/Sync/MediaSync.cs index cc4b4d5c3..b6853267e 100644 --- a/MediaBrowser.Server.Implementations/Sync/MediaSync.cs +++ b/MediaBrowser.Server.Implementations/Sync/MediaSync.cs @@ -18,7 +18,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; -using Interfaces.IO; using MediaBrowser.Common.IO; using MediaBrowser.Server.Implementations.IO; diff --git a/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs b/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs index 875575daf..03df0d4e6 100644 --- a/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs +++ b/MediaBrowser.Server.Implementations/Sync/TargetDataProvider.cs @@ -6,15 +6,10 @@ using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Sync; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; -using Interfaces.IO; -using MediaBrowser.Common.IO; -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; namespace MediaBrowser.Server.Implementations.Sync { diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index c64db7d47..b1b1abf14 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -2,10 +2,8 @@ - - + - \ No newline at end of file diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 1376d0a45..215ee4468 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -1,4 +1,3 @@ -using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Mono.Native; @@ -14,6 +13,7 @@ using System.Reflection; using System.Security.Cryptography.X509Certificates; using System.Threading.Tasks; using Emby.Common.Implementations.IO; +using Emby.Common.Implementations.Logging; namespace MediaBrowser.Server.Mono { diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 459500792..39c18c32e 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -6,7 +6,6 @@ using MediaBrowser.Common; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Implementations; using Emby.Common.Implementations.ScheduledTasks; using MediaBrowser.Common.Net; using MediaBrowser.Common.Progress; diff --git a/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs b/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs index 804533b9d..696c3892e 100644 --- a/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs +++ b/MediaBrowser.Server.Startup.Common/UnhandledExceptionWriter.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Implementations.Logging; using MediaBrowser.Model.Logging; using System; using System.IO; diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 39940cf7f..18fa80fe2 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Implementations.Logging; -using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Startup.Common; using MediaBrowser.Server.Startup.Common.Browser; @@ -20,6 +19,7 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Emby.Common.Implementations.IO; +using Emby.Common.Implementations.Logging; using ImageMagickSharp; using MediaBrowser.Common.Net; -- cgit v1.2.3