mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-06 06:12:52 +01:00
Add GPL modules
This commit is contained in:
7
MediaBrowser.Model/Logging/IConsoleLogger.cs
Normal file
7
MediaBrowser.Model/Logging/IConsoleLogger.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace MediaBrowser.Model.Logging
|
||||
{
|
||||
public interface IConsoleLogger
|
||||
{
|
||||
void WriteLine(string message);
|
||||
}
|
||||
}
|
||||
56
MediaBrowser.Model/Logging/ILogManager.cs
Normal file
56
MediaBrowser.Model/Logging/ILogManager.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
78
MediaBrowser.Model/Logging/ILogger.cs
Normal file
78
MediaBrowser.Model/Logging/ILogger.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
97
MediaBrowser.Model/Logging/LogHelper.cs
Normal file
97
MediaBrowser.Model/Logging/LogHelper.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
MediaBrowser.Model/Logging/LogSeverity.cs
Normal file
30
MediaBrowser.Model/Logging/LogSeverity.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
44
MediaBrowser.Model/Logging/NullLogger.cs
Normal file
44
MediaBrowser.Model/Logging/NullLogger.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user