Merge pull request #390 from Bond-009/logging

Remove remaining part of old logging code
This commit is contained in:
Vasily 2019-01-06 02:48:16 +03:00 committed by GitHub
commit d5d9dfd8e6

View File

@ -421,8 +421,6 @@ namespace Emby.Server.Implementations
ImageEncoder = imageEncoder; ImageEncoder = imageEncoder;
//SetBaseExceptionMessage();
fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));
NetworkManager.NetworkChanged += NetworkManager_NetworkChanged; NetworkManager.NetworkChanged += NetworkManager_NetworkChanged;
@ -687,18 +685,6 @@ namespace Emby.Server.Implementations
return parts; return parts;
} }
// TODO: @bond
/*
private void SetBaseExceptionMessage()
{
var builder = GetBaseExceptionMessage(ApplicationPaths);
builder.Insert(0, string.Format("Version: {0}{1}", ApplicationVersion, Environment.NewLine));
builder.Insert(0, "*** Error Report ***" + Environment.NewLine);
LoggerFactory.ExceptionMessagePrefix = builder.ToString();
}*/
/// <summary> /// <summary>
/// Runs the startup tasks. /// Runs the startup tasks.
/// </summary> /// </summary>
@ -734,8 +720,6 @@ namespace Emby.Server.Implementations
RunEntryPoints(entryPoints, false); RunEntryPoints(entryPoints, false);
Logger.LogInformation("All entry points have started"); Logger.LogInformation("All entry points have started");
//LoggerFactory.RemoveConsoleOutput();
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -749,7 +733,7 @@ namespace Emby.Server.Implementations
} }
var name = entryPoint.GetType().FullName; var name = entryPoint.GetType().FullName;
Logger.LogInformation("Starting entry point {0}", name); Logger.LogInformation("Starting entry point {Name}", name);
var now = DateTime.UtcNow; var now = DateTime.UtcNow;
try try
{ {
@ -757,9 +741,9 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError(ex, "Error in {name}", name); Logger.LogError(ex, "Error while running entrypoint {Name}", name);
} }
Logger.LogInformation("Entry point completed: {0}. Duration: {1} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos"); Logger.LogInformation("Entry point completed: {Name}. Duration: {Duration} seconds", name, (DateTime.UtcNow - now).TotalSeconds.ToString(CultureInfo.InvariantCulture), "ImageInfos");
} }
} }
@ -1380,12 +1364,11 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError(ex, "Error getting plugin Id from {pluginName}.", plugin.GetType().FullName); Logger.LogError(ex, "Error getting plugin Id from {PluginName}.", plugin.GetType().FullName);
} }
} }
var hasPluginConfiguration = plugin as IHasPluginConfiguration; if (plugin is IHasPluginConfiguration hasPluginConfiguration)
if (hasPluginConfiguration != null)
{ {
hasPluginConfiguration.SetStartupInfo(s => Directory.CreateDirectory(s)); hasPluginConfiguration.SetStartupInfo(s => Directory.CreateDirectory(s));
} }
@ -1804,13 +1787,13 @@ namespace Emby.Server.Implementations
{ {
var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion); var result = Version.Parse(FileVersionInfo.GetVersionInfo(path).FileVersion);
Logger.LogInformation("File {0} has version {1}", path, result); Logger.LogInformation("File {Path} has version {Version}", path, result);
return result; return result;
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError(ex, "Error getting version number from {path}", path); Logger.LogError(ex, "Error getting version number from {Path}", path);
return new Version(1, 0); return new Version(1, 0);
} }
@ -2386,15 +2369,14 @@ namespace Emby.Server.Implementations
{ {
var type = GetType(); var type = GetType();
//LoggerFactory.AddConsoleOutput(); Logger.LogInformation("Disposing {Type}", type.Name);
Logger.LogInformation("Disposing " + type.Name);
var parts = DisposableParts.Distinct().Where(i => i.GetType() != type).ToList(); var parts = DisposableParts.Distinct().Where(i => i.GetType() != type).ToList();
DisposableParts.Clear(); DisposableParts.Clear();
foreach (var part in parts) foreach (var part in parts)
{ {
Logger.LogInformation("Disposing " + part.GetType().Name); Logger.LogInformation("Disposing {Type}", part.GetType().Name);
try try
{ {
@ -2402,7 +2384,7 @@ namespace Emby.Server.Implementations
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError(ex, "Error disposing {0}", part.GetType().Name); Logger.LogError(ex, "Error disposing {Type}", part.GetType().Name);
} }
} }
} }