|
|
|
@ -9,12 +9,20 @@ namespace NzbDrone.Common.Instrumentation
|
|
|
|
|
{
|
|
|
|
|
public static class LoggerExtensions
|
|
|
|
|
{
|
|
|
|
|
public static void Complete(this Logger logger, string message)
|
|
|
|
|
public static void Progress(this Logger logger, string message)
|
|
|
|
|
{
|
|
|
|
|
var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message);
|
|
|
|
|
logEvent.Properties.Add("Status", ProcessState.Completed);
|
|
|
|
|
LogProgressMessage(logger, message, ProcessState.Running);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.Log(logEvent);
|
|
|
|
|
public static void Progress(this Logger logger, string message, params object[] args)
|
|
|
|
|
{
|
|
|
|
|
var formattedMessage = String.Format(message, args);
|
|
|
|
|
Progress(logger, formattedMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Complete(this Logger logger, string message)
|
|
|
|
|
{
|
|
|
|
|
LogProgressMessage(logger, message, ProcessState.Completed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Complete(this Logger logger, string message, params object[] args)
|
|
|
|
@ -25,10 +33,7 @@ namespace NzbDrone.Common.Instrumentation
|
|
|
|
|
|
|
|
|
|
public static void Failed(this Logger logger, string message)
|
|
|
|
|
{
|
|
|
|
|
var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message);
|
|
|
|
|
logEvent.Properties.Add("Status", ProcessState.Failed);
|
|
|
|
|
|
|
|
|
|
logger.Log(logEvent);
|
|
|
|
|
LogProgressMessage(logger, message, ProcessState.Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Failed(this Logger logger, string message, params object[] args)
|
|
|
|
@ -36,5 +41,13 @@ namespace NzbDrone.Common.Instrumentation
|
|
|
|
|
var formattedMessage = String.Format(message, args);
|
|
|
|
|
Failed(logger, formattedMessage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void LogProgressMessage(Logger logger, string message, ProcessState state)
|
|
|
|
|
{
|
|
|
|
|
var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message);
|
|
|
|
|
logEvent.Properties.Add("Status", state);
|
|
|
|
|
|
|
|
|
|
logger.Log(logEvent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|