jellyfin/MediaBrowser.Server.Implementations/HttpServer/ServerLogger.cs

195 lines
6.0 KiB
C#
Raw Normal View History

2013-04-17 12:53:31 -07:00
using MediaBrowser.Model.Logging;
using ServiceStack.Logging;
using System;
namespace MediaBrowser.Server.Implementations.HttpServer
{
/// <summary>
/// Class ServerLogger
/// </summary>
public class ServerLogger : ILog
{
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="ServerLogger"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
public ServerLogger(ILogger logger)
{
_logger = logger;
}
/// <summary>
/// Logs a Debug message and exception.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
public void Debug(object message, Exception exception)
{
_logger.ErrorException(GetMesssage(message), exception);
}
/// <summary>
/// Logs a Debug message.
/// </summary>
/// <param name="message">The message.</param>
public void Debug(object message)
{
2013-05-20 20:13:30 -07:00
// Way too verbose. Can always make this configurable if needed again.
//_logger.Debug(GetMesssage(message));
2013-04-17 12:53:31 -07:00
}
/// <summary>
/// Logs a Debug format message.
/// </summary>
/// <param name="format">The format.</param>
/// <param name="args">The args.</param>
public void DebugFormat(string format, params object[] args)
{
2013-05-20 20:13:30 -07:00
// Way too verbose. Can always make this configurable if needed again.
//_logger.Debug(format, args);
2013-04-17 12:53:31 -07:00
}
/// <summary>
/// Logs a Error message and exception.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
public void Error(object message, Exception exception)
{
_logger.ErrorException(GetMesssage(message), exception);
}
/// <summary>
/// Logs a Error message.
/// </summary>
/// <param name="message">The message.</param>
public void Error(object message)
{
_logger.Error(GetMesssage(message));
}
/// <summary>
/// Logs a Error format message.
/// </summary>
/// <param name="format">The format.</param>
/// <param name="args">The args.</param>
public void ErrorFormat(string format, params object[] args)
{
_logger.Error(format, args);
}
/// <summary>
/// Logs a Fatal message and exception.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
public void Fatal(object message, Exception exception)
{
_logger.FatalException(GetMesssage(message), exception);
}
/// <summary>
/// Logs a Fatal message.
/// </summary>
/// <param name="message">The message.</param>
public void Fatal(object message)
{
_logger.Fatal(GetMesssage(message));
}
/// <summary>
/// Logs a Error format message.
/// </summary>
/// <param name="format">The format.</param>
/// <param name="args">The args.</param>
public void FatalFormat(string format, params object[] args)
{
_logger.Fatal(format, args);
}
/// <summary>
/// Logs an Info message and exception.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
public void Info(object message, Exception exception)
{
_logger.ErrorException(GetMesssage(message), exception);
}
/// <summary>
/// Logs an Info message and exception.
/// </summary>
/// <param name="message">The message.</param>
public void Info(object message)
{
_logger.Info(GetMesssage(message));
}
/// <summary>
/// Logs an Info format message.
/// </summary>
/// <param name="format">The format.</param>
/// <param name="args">The args.</param>
public void InfoFormat(string format, params object[] args)
{
_logger.Info(format, args);
}
/// <summary>
/// Gets or sets a value indicating whether this instance is debug enabled.
/// </summary>
/// <value><c>true</c> if this instance is debug enabled; otherwise, <c>false</c>.</value>
public bool IsDebugEnabled
{
get { return true; }
}
/// <summary>
/// Logs a Warning message and exception.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
public void Warn(object message, Exception exception)
{
_logger.ErrorException(GetMesssage(message), exception);
}
/// <summary>
/// Logs a Warning message.
/// </summary>
/// <param name="message">The message.</param>
public void Warn(object message)
{
2014-05-06 19:28:19 -07:00
// Hide StringMapTypeDeserializer messages
// _logger.Warn(GetMesssage(message));
2013-04-17 12:53:31 -07:00
}
/// <summary>
/// Logs a Warning format message.
/// </summary>
/// <param name="format">The format.</param>
/// <param name="args">The args.</param>
public void WarnFormat(string format, params object[] args)
{
2014-05-06 19:28:19 -07:00
// Hide StringMapTypeDeserializer messages
// _logger.Warn(format, args);
2013-04-17 12:53:31 -07:00
}
/// <summary>
/// Gets the messsage.
/// </summary>
/// <param name="o">The o.</param>
/// <returns>System.String.</returns>
private string GetMesssage(object o)
{
return o == null ? string.Empty : o.ToString();
}
}
}