mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
3.0.5464.40000
This commit is contained in:
@@ -294,19 +294,20 @@ namespace MediaBrowser.Common.Implementations
|
||||
|
||||
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, bool isStartup)
|
||||
{
|
||||
if (isStartup)
|
||||
{
|
||||
logger.Info("Media Browser Server started");
|
||||
}
|
||||
logger.LogMultiline("Media Browser", LogSeverity.Info, GetBaseExceptionMessage(appPaths));
|
||||
}
|
||||
|
||||
logger.Info("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs()));
|
||||
protected static StringBuilder GetBaseExceptionMessage(IApplicationPaths appPaths)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
|
||||
logger.Info("Server: {0}", Environment.MachineName);
|
||||
logger.Info("Operating system: {0}", Environment.OSVersion.ToString());
|
||||
logger.Info("Processor count: {0}", Environment.ProcessorCount);
|
||||
logger.Info("64-Bit OS: {0}", Environment.Is64BitOperatingSystem);
|
||||
logger.Info("64-Bit Process: {0}", Environment.Is64BitProcess);
|
||||
logger.Info("Program data path: {0}", appPaths.ProgramDataPath);
|
||||
builder.AppendLine(string.Format("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs())));
|
||||
|
||||
builder.AppendLine(string.Format("Operating system: {0}", Environment.OSVersion));
|
||||
builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount));
|
||||
builder.AppendLine(string.Format("64-Bit OS: {0}", Environment.Is64BitOperatingSystem));
|
||||
builder.AppendLine(string.Format("64-Bit Process: {0}", Environment.Is64BitProcess));
|
||||
builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath));
|
||||
|
||||
Type type = Type.GetType("Mono.Runtime");
|
||||
if (type != null)
|
||||
@@ -314,13 +315,13 @@ namespace MediaBrowser.Common.Implementations
|
||||
MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (displayName != null)
|
||||
{
|
||||
logger.Info("Mono: " + displayName.Invoke(null, null));
|
||||
builder.AppendLine("Mono: " + displayName.Invoke(null, null));
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("Application Path: {0}", appPaths.ApplicationPath);
|
||||
}
|
||||
|
||||
logger.Info("*** When reporting issues please include the entire log file. ***".ToUpper());
|
||||
builder.AppendLine(string.Format("Application Path: {0}", appPaths.ApplicationPath));
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
protected virtual IJsonSerializer CreateJsonSerializer()
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
/// </summary>
|
||||
private readonly NLog.Logger _logger;
|
||||
|
||||
private readonly ILogManager _logManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _lock object
|
||||
/// </summary>
|
||||
@@ -23,8 +25,10 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
/// Initializes a new instance of the <see cref="NLogger" /> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
public NLogger(string name)
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
public NLogger(string name, ILogManager logManager)
|
||||
{
|
||||
_logManager = logManager;
|
||||
lock (LockObject)
|
||||
{
|
||||
_logger = NLog.LogManager.GetLogger(name);
|
||||
@@ -96,6 +100,13 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
|
||||
var messageText = LogHelper.GetLogMessage(exception);
|
||||
|
||||
var prefix = _logManager.ExceptionMessagePrefix;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(prefix))
|
||||
{
|
||||
messageText.Insert(0, prefix);
|
||||
}
|
||||
|
||||
LogMultiline(message, level, messageText);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,12 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
/// <value>The log file path.</value>
|
||||
public string LogFilePath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exception message prefix.
|
||||
/// </summary>
|
||||
/// <value>The exception message prefix.</value>
|
||||
public string ExceptionMessagePrefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NlogManager" /> class.
|
||||
/// </summary>
|
||||
@@ -159,7 +165,7 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
/// <returns>ILogger.</returns>
|
||||
public ILogger GetLogger(string name)
|
||||
{
|
||||
return new NLogger(name);
|
||||
return new NLogger(name, this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user