|
@ -1,4 +1,5 @@ |
|
|
using System; |
|
|
using System; |
|
|
|
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
|
|
|
|
namespace IPA.Logging |
|
|
namespace IPA.Logging |
|
@ -9,6 +10,7 @@ namespace IPA.Logging |
|
|
public abstract class Logger |
|
|
public abstract class Logger |
|
|
{ |
|
|
{ |
|
|
private static Logger _log; |
|
|
private static Logger _log; |
|
|
|
|
|
|
|
|
internal static Logger log |
|
|
internal static Logger log |
|
|
{ |
|
|
{ |
|
|
get |
|
|
get |
|
@ -18,6 +20,7 @@ namespace IPA.Logging |
|
|
return _log; |
|
|
return _log; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
internal static Logger updater => log.GetChildLogger("Updater"); |
|
|
internal static Logger updater => log.GetChildLogger("Updater"); |
|
|
internal static Logger libLoader => log.GetChildLogger("LibraryLoader"); |
|
|
internal static Logger libLoader => log.GetChildLogger("LibraryLoader"); |
|
|
internal static Logger loader => log.GetChildLogger("Loader"); |
|
|
internal static Logger loader => log.GetChildLogger("Loader"); |
|
@ -38,22 +41,27 @@ namespace IPA.Logging |
|
|
/// No associated level. These never get shown.
|
|
|
/// No associated level. These never get shown.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
None = 0, |
|
|
None = 0, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// A debug message.
|
|
|
/// A debug message.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
Debug = 1, |
|
|
Debug = 1, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// An informational message.
|
|
|
/// An informational message.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
Info = 2, |
|
|
Info = 2, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// A warning message.
|
|
|
/// A warning message.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
Warning = 4, |
|
|
Warning = 4, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// An error message.
|
|
|
/// An error message.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
Error = 8, |
|
|
Error = 8, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// A critical error message.
|
|
|
/// A critical error message.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -70,22 +78,27 @@ namespace IPA.Logging |
|
|
/// Allow no messages through.
|
|
|
/// Allow no messages through.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
None = Level.None, |
|
|
None = Level.None, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Only shows Debug messages.
|
|
|
/// Only shows Debug messages.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
DebugOnly = Level.Debug, |
|
|
DebugOnly = Level.Debug, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Only shows info messages.
|
|
|
/// Only shows info messages.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
InfoOnly = Level.Info, |
|
|
InfoOnly = Level.Info, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Only shows Warning messages.
|
|
|
/// Only shows Warning messages.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
WarningOnly = Level.Warning, |
|
|
WarningOnly = Level.Warning, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Only shows Error messages.
|
|
|
/// Only shows Error messages.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
ErrorOnly = Level.Error, |
|
|
ErrorOnly = Level.Error, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Only shows Critical messages.
|
|
|
/// Only shows Critical messages.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -95,14 +108,17 @@ namespace IPA.Logging |
|
|
/// Shows all messages error and up.
|
|
|
/// Shows all messages error and up.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
ErrorUp = ErrorOnly | CriticalOnly, |
|
|
ErrorUp = ErrorOnly | CriticalOnly, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Shows all messages warning and up.
|
|
|
/// Shows all messages warning and up.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
WarningUp = WarningOnly | ErrorUp, |
|
|
WarningUp = WarningOnly | ErrorUp, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Shows all messages info and up.
|
|
|
/// Shows all messages info and up.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
InfoUp = InfoOnly | WarningUp, |
|
|
InfoUp = InfoOnly | WarningUp, |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Shows all messages.
|
|
|
/// Shows all messages.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -120,19 +136,22 @@ namespace IPA.Logging |
|
|
/// <param name="level">the level of the message</param>
|
|
|
/// <param name="level">the level of the message</param>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
public abstract void Log(Level level, string message); |
|
|
public abstract void Log(Level level, string message); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// A basic log function taking an exception to log.
|
|
|
/// A basic log function taking an exception to log.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="level">the level of the message</param>
|
|
|
/// <param name="level">the level of the message</param>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
public virtual void Log(Level level, Exception e) => Log(level, e.ToString()); |
|
|
public virtual void Log(Level level, Exception e) => Log(level, e.ToString()); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends a debug message.
|
|
|
|
|
|
|
|
|
/// Sends a debug message.
|
|
|
/// Equivalent to Log(Level.Debug, message);
|
|
|
/// Equivalent to Log(Level.Debug, message);
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
public virtual void Debug(string message) => Log(Level.Debug, message); |
|
|
public virtual void Debug(string message) => Log(Level.Debug, message); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends an exception as a debug message.
|
|
|
/// Sends an exception as a debug message.
|
|
|
/// Equivalent to Log(Level.Debug, e);
|
|
|
/// Equivalent to Log(Level.Debug, e);
|
|
@ -140,13 +159,15 @@ namespace IPA.Logging |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
public virtual void Debug(Exception e) => Log(Level.Debug, e); |
|
|
public virtual void Debug(Exception e) => Log(Level.Debug, e); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends an info message.
|
|
|
|
|
|
|
|
|
/// Sends an info message.
|
|
|
/// Equivalent to Log(Level.Info, message).
|
|
|
/// Equivalent to Log(Level.Info, message).
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
public virtual void Info(string message) => Log(Level.Info, message); |
|
|
public virtual void Info(string message) => Log(Level.Info, message); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends an exception as an info message.
|
|
|
/// Sends an exception as an info message.
|
|
|
/// Equivalent to Log(Level.Info, e);
|
|
|
/// Equivalent to Log(Level.Info, e);
|
|
@ -154,13 +175,15 @@ namespace IPA.Logging |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
public virtual void Info(Exception e) => Log(Level.Info, e); |
|
|
public virtual void Info(Exception e) => Log(Level.Info, e); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends a warning message.
|
|
|
|
|
|
|
|
|
/// Sends a warning message.
|
|
|
/// Equivalent to Log(Level.Warning, message).
|
|
|
/// Equivalent to Log(Level.Warning, message).
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
public virtual void Warn(string message) => Log(Level.Warning, message); |
|
|
public virtual void Warn(string message) => Log(Level.Warning, message); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends an exception as a warning message.
|
|
|
/// Sends an exception as a warning message.
|
|
|
/// Equivalent to Log(Level.Warning, e);
|
|
|
/// Equivalent to Log(Level.Warning, e);
|
|
@ -168,13 +191,15 @@ namespace IPA.Logging |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
public virtual void Warn(Exception e) => Log(Level.Warning, e); |
|
|
public virtual void Warn(Exception e) => Log(Level.Warning, e); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends an error message.
|
|
|
|
|
|
|
|
|
/// Sends an error message.
|
|
|
/// Equivalent to Log(Level.Error, message).
|
|
|
/// Equivalent to Log(Level.Error, message).
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
public virtual void Error(string message) => Log(Level.Error, message); |
|
|
public virtual void Error(string message) => Log(Level.Error, message); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends an exception as an error message.
|
|
|
/// Sends an exception as an error message.
|
|
|
/// Equivalent to Log(Level.Error, e);
|
|
|
/// Equivalent to Log(Level.Error, e);
|
|
@ -182,13 +207,15 @@ namespace IPA.Logging |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
public virtual void Error(Exception e) => Log(Level.Error, e); |
|
|
public virtual void Error(Exception e) => Log(Level.Error, e); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends a critical message.
|
|
|
|
|
|
|
|
|
/// Sends a critical message.
|
|
|
/// Equivalent to Log(Level.Critical, message).
|
|
|
/// Equivalent to Log(Level.Critical, message).
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// <see cref="Log(Level, string)"/>
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
/// <param name="message">the message to log</param>
|
|
|
public virtual void Critical(string message) => Log(Level.Critical, message); |
|
|
public virtual void Critical(string message) => Log(Level.Critical, message); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Sends an exception as a critical message.
|
|
|
/// Sends an exception as a critical message.
|
|
|
/// Equivalent to Log(Level.Critical, e);
|
|
|
/// Equivalent to Log(Level.Critical, e);
|
|
@ -197,4 +224,4 @@ namespace IPA.Logging |
|
|
/// <param name="e">the exception to log</param>
|
|
|
/// <param name="e">the exception to log</param>
|
|
|
public virtual void Critical(Exception e) => Log(Level.Critical, e); |
|
|
public virtual void Critical(Exception e) => Log(Level.Critical, e); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |