mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-25 11:34:43 +01:00
Use Microsoft.Extensions.Logging abstraction
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Activity
|
||||
@@ -63,6 +63,6 @@ namespace MediaBrowser.Model.Activity
|
||||
/// Gets or sets the log severity.
|
||||
/// </summary>
|
||||
/// <value>The log severity.</value>
|
||||
public LogSeverity Severity { get; set; }
|
||||
public LogLevel Severity { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Session;
|
||||
using System;
|
||||
@@ -528,7 +528,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
transcodeReasons.InsertRange(0, GetTranscodeReasonsFromDirectPlayProfile(item, null, audioStream, options.Profile.DirectPlayProfiles));
|
||||
|
||||
_logger.Info("Profile: {0}, No direct play profiles found for Path: {1}",
|
||||
_logger.LogInformation("Profile: {0}, No direct play profiles found for Path: {1}",
|
||||
options.Profile.Name ?? "Unknown Profile",
|
||||
item.Path ?? "Unknown path");
|
||||
}
|
||||
@@ -732,7 +732,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
bool isEligibleForDirectPlay = options.EnableDirectPlay && (options.ForceDirectPlay || directPlayEligibilityResult.Item1);
|
||||
bool isEligibleForDirectStream = options.EnableDirectStream && (options.ForceDirectStream || directStreamEligibilityResult.Item1);
|
||||
|
||||
_logger.Info("Profile: {0}, Path: {1}, isEligibleForDirectPlay: {2}, isEligibleForDirectStream: {3}",
|
||||
_logger.LogInformation("Profile: {0}, Path: {1}, isEligibleForDirectPlay: {2}, isEligibleForDirectStream: {3}",
|
||||
options.Profile.Name ?? "Unknown Profile",
|
||||
item.Path ?? "Unknown path",
|
||||
isEligibleForDirectPlay,
|
||||
@@ -1022,7 +1022,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
if (directPlay == null)
|
||||
{
|
||||
_logger.Info("Profile: {0}, No direct play profiles found for Path: {1}",
|
||||
_logger.LogInformation("Profile: {0}, No direct play profiles found for Path: {1}",
|
||||
profile.Name ?? "Unknown Profile",
|
||||
mediaSource.Path ?? "Unknown path");
|
||||
|
||||
@@ -1188,7 +1188,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
private void LogConditionFailure(DeviceProfile profile, string type, ProfileCondition condition, MediaSourceInfo mediaSource)
|
||||
{
|
||||
_logger.Info("Profile: {0}, DirectPlay=false. Reason={1}.{2} Condition: {3}. ConditionValue: {4}. IsRequired: {5}. Path: {6}",
|
||||
_logger.LogInformation("Profile: {0}, DirectPlay=false. Reason={1}.{2} Condition: {3}. ConditionValue: {4}. IsRequired: {5}. Path: {6}",
|
||||
type,
|
||||
profile.Name ?? "Unknown Profile",
|
||||
condition.Property,
|
||||
@@ -1210,7 +1210,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed)
|
||||
{
|
||||
_logger.Info("Not eligible for {0} due to unsupported subtitles", playMethod);
|
||||
_logger.LogInformation("Not eligible for {0} due to unsupported subtitles", playMethod);
|
||||
return new ValueTuple<bool, TranscodeReason?>(false, TranscodeReason.SubtitleCodecNotSupported);
|
||||
}
|
||||
}
|
||||
@@ -1397,7 +1397,7 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
if (itemBitrate > requestedMaxBitrate)
|
||||
{
|
||||
_logger.Info("Bitrate exceeds " + playMethod + " limit: media bitrate: {0}, max bitrate: {1}", itemBitrate.ToString(CultureInfo.InvariantCulture), requestedMaxBitrate.ToString(CultureInfo.InvariantCulture));
|
||||
_logger.LogInformation("Bitrate exceeds " + playMethod + " limit: media bitrate: {0}, max bitrate: {1}", itemBitrate.ToString(CultureInfo.InvariantCulture), requestedMaxBitrate.ToString(CultureInfo.InvariantCulture));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace MediaBrowser.Model.Logging
|
||||
{
|
||||
public interface IConsoleLogger
|
||||
{
|
||||
void WriteLine(string message);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Model.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface ILogManager
|
||||
/// </summary>
|
||||
public interface ILogManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the log level.
|
||||
/// </summary>
|
||||
/// <value>The log level.</value>
|
||||
LogSeverity LogSeverity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exception message prefix.
|
||||
/// </summary>
|
||||
/// <value>The exception message prefix.</value>
|
||||
string ExceptionMessagePrefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <returns>ILogger.</returns>
|
||||
ILogger GetLogger(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the logger.
|
||||
/// </summary>
|
||||
Task ReloadLogger(LogSeverity severity, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [logger loaded].
|
||||
/// </summary>
|
||||
event EventHandler LoggerLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Flushes this instance.
|
||||
/// </summary>
|
||||
void Flush();
|
||||
|
||||
/// <summary>
|
||||
/// Adds the console output.
|
||||
/// </summary>
|
||||
void AddConsoleOutput();
|
||||
|
||||
/// <summary>
|
||||
/// Removes the console output.
|
||||
/// </summary>
|
||||
void RemoveConsoleOutput();
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.Model.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface ILogger
|
||||
/// </summary>
|
||||
public interface ILogger
|
||||
{
|
||||
/// <summary>
|
||||
/// Infoes the specified message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="paramList">The param list.</param>
|
||||
void Info(string message, params object[] paramList);
|
||||
|
||||
/// <summary>
|
||||
/// Errors the specified message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="paramList">The param list.</param>
|
||||
void Error(string message, params object[] paramList);
|
||||
|
||||
/// <summary>
|
||||
/// Warns the specified message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="paramList">The param list.</param>
|
||||
void Warn(string message, params object[] paramList);
|
||||
|
||||
/// <summary>
|
||||
/// Debugs the specified message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="paramList">The param list.</param>
|
||||
void Debug(string message, params object[] paramList);
|
||||
|
||||
/// <summary>
|
||||
/// Fatals the specified message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="paramList">The param list.</param>
|
||||
void Fatal(string message, params object[] paramList);
|
||||
|
||||
/// <summary>
|
||||
/// Fatals the exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="exception">The exception.</param>
|
||||
/// <param name="paramList">The param list.</param>
|
||||
void FatalException(string message, Exception exception, params object[] paramList);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="exception">The exception.</param>
|
||||
/// <param name="paramList">The param list.</param>
|
||||
void ErrorException(string message, Exception exception, params object[] paramList);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the multiline.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="severity">The severity.</param>
|
||||
/// <param name="additionalContent">Content of the additional.</param>
|
||||
void LogMultiline(string message, LogSeverity severity, StringBuilder additionalContent);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified severity.
|
||||
/// </summary>
|
||||
/// <param name="severity">The severity.</param>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="paramList">The parameter list.</param>
|
||||
void Log(LogSeverity severity, string message, params object[] paramList);
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.Model.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Class LogHelper
|
||||
/// </summary>
|
||||
public static class LogHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the log message.
|
||||
/// </summary>
|
||||
/// <param name="exception">The exception.</param>
|
||||
/// <returns>StringBuilder.</returns>
|
||||
public static StringBuilder GetLogMessage(Exception exception)
|
||||
{
|
||||
if (exception == null)
|
||||
{
|
||||
throw new ArgumentNullException("exception");
|
||||
}
|
||||
|
||||
var messageText = new StringBuilder();
|
||||
|
||||
messageText.AppendLine(exception.ToString());
|
||||
|
||||
messageText.AppendLine(exception.GetType().FullName);
|
||||
|
||||
LogExceptionData(messageText, exception);
|
||||
|
||||
messageText.AppendLine(exception.StackTrace ?? "No Stack Trace Available");
|
||||
|
||||
// Log the InnerExceptions, if any
|
||||
AppendInnerExceptions(messageText, exception);
|
||||
|
||||
messageText.AppendLine(string.Empty);
|
||||
|
||||
return messageText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the inner exceptions.
|
||||
/// </summary>
|
||||
/// <param name="messageText">The message text.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
private static void AppendInnerExceptions(StringBuilder messageText, Exception e)
|
||||
{
|
||||
var aggregate = e as AggregateException;
|
||||
|
||||
if (aggregate != null && aggregate.InnerExceptions != null)
|
||||
{
|
||||
foreach (var ex in aggregate.InnerExceptions)
|
||||
{
|
||||
AppendInnerException(messageText, ex);
|
||||
AppendInnerExceptions(messageText, ex);
|
||||
}
|
||||
}
|
||||
|
||||
else if (e.InnerException != null)
|
||||
{
|
||||
AppendInnerException(messageText, e.InnerException);
|
||||
AppendInnerExceptions(messageText, e.InnerException);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Appends the inner exception.
|
||||
/// </summary>
|
||||
/// <param name="messageText">The message text.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
private static void AppendInnerException(StringBuilder messageText, Exception e)
|
||||
{
|
||||
messageText.AppendLine("InnerException: " + e.GetType().FullName);
|
||||
messageText.AppendLine(e.ToString());
|
||||
|
||||
LogExceptionData(messageText, e);
|
||||
|
||||
if (e.StackTrace != null)
|
||||
{
|
||||
messageText.AppendLine(e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the exception data.
|
||||
/// </summary>
|
||||
/// <param name="messageText">The message text.</param>
|
||||
/// <param name="e">The e.</param>
|
||||
private static void LogExceptionData(StringBuilder messageText, Exception e)
|
||||
{
|
||||
foreach (var key in e.Data.Keys)
|
||||
{
|
||||
messageText.AppendLine(key + ": " + e.Data[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
namespace MediaBrowser.Model.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum LogSeverity
|
||||
/// </summary>
|
||||
public enum LogSeverity
|
||||
{
|
||||
/// <summary>
|
||||
/// The info
|
||||
/// </summary>
|
||||
Info,
|
||||
/// <summary>
|
||||
/// The debug
|
||||
/// </summary>
|
||||
Debug,
|
||||
/// <summary>
|
||||
/// The warn
|
||||
/// </summary>
|
||||
Warn,
|
||||
/// <summary>
|
||||
/// The error
|
||||
/// </summary>
|
||||
Error,
|
||||
/// <summary>
|
||||
/// The fatal
|
||||
/// </summary>
|
||||
Fatal
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace MediaBrowser.Model.Logging
|
||||
{
|
||||
public class NullLogger : ILogger
|
||||
{
|
||||
public void Info(string message, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(string message, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warn(string message, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug(string message, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(string message, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void FatalException(string message, Exception exception, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void Log(LogSeverity severity, string message, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void ErrorException(string message, Exception exception, params object[] paramList)
|
||||
{
|
||||
}
|
||||
|
||||
public void LogMultiline(string message, LogSeverity severity, StringBuilder additionalContent)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SharedVersion.cs"/>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using MediaBrowser.Model.Events;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
@@ -29,4 +29,4 @@ namespace MediaBrowser.Model.Tasks
|
||||
/// </summary>
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user