Browse Source

Added trace log level

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
0dda45d526
4 changed files with 49 additions and 3 deletions
  1. +8
    -0
      IPA.Loader/Config/SelfConfig.cs
  2. +29
    -1
      IPA.Loader/Logging/Logger.cs
  3. +4
    -2
      IPA.Loader/Logging/StandardLogger.cs
  4. +8
    -0
      docs/articles/command-line.md

+ 8
- 0
IPA.Loader/Config/SelfConfig.cs View File

@ -59,6 +59,9 @@ namespace IPA.Config
CommandLineValues.Updates.AutoCheckUpdates = false; CommandLineValues.Updates.AutoCheckUpdates = false;
CommandLineValues.Updates.AutoUpdate = false; CommandLineValues.Updates.AutoUpdate = false;
break; break;
case "--trace":
CommandLineValues.Debug.ShowTrace = true;
break;
} }
} }
} }
@ -118,6 +121,11 @@ namespace IPA.Config
public int HideLogThreshold = 512; public int HideLogThreshold = 512;
// LINE: ignore // LINE: ignore
public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold; public static int HideLogThreshold_ => SelfConfigRef.Value.Debug.HideLogThreshold;
public bool ShowTrace = false;
// LINE: ignore 2
public static bool ShowTrace_ => SelfConfigRef.Value.Debug.ShowTrace
|| CommandLineValues.Debug.ShowTrace;
} }
public Debug_ Debug = new Debug_(); public Debug_ Debug = new Debug_();


+ 29
- 1
IPA.Loader/Logging/Logger.cs View File

@ -56,6 +56,11 @@ namespace IPA.Logging
/// </summary> /// </summary>
None = 0, None = 0,
/// <summary>
/// A trace message. These are ignored *incredibly* early.
/// </summary>
Trace = 32,
/// <summary> /// <summary>
/// A debug message. /// A debug message.
/// </summary> /// </summary>
@ -98,6 +103,8 @@ namespace IPA.Logging
/// </summary> /// </summary>
None = Level.None, None = Level.None,
TraceOnly = Level.Trace,
/// <summary> /// <summary>
/// Only shows Debug messages. /// Only shows Debug messages.
/// </summary> /// </summary>
@ -148,10 +155,15 @@ namespace IPA.Logging
/// </summary> /// </summary>
InfoUp = InfoOnly | NoticeUp, InfoUp = InfoOnly | NoticeUp,
/// <summary>
/// Shows all messages debug and up.
/// </summary>
DebugUp = DebugOnly | InfoUp,
/// <summary> /// <summary>
/// Shows all messages. /// Shows all messages.
/// </summary> /// </summary>
All = DebugOnly | InfoUp,
All = TraceOnly | DebugUp,
/// <summary> /// <summary>
/// Used for when the level is undefined. /// Used for when the level is undefined.
@ -173,6 +185,22 @@ namespace IPA.Logging
/// <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>
/// Sends a trace message.
/// Equivalent to `Log(Level.Trace, message);`
/// </summary>
/// <seealso cref="Log(Level, string)"/>
/// <param name="message">the message to log</param>
public virtual void Trace(string message) => Log(Level.Trace, message);
/// <summary>
/// Sends an exception as a trace message.
/// Equivalent to `Log(Level.Trace, e);`
/// </summary>
/// <seealso cref="Log(Level, Exception)"/>
/// <param name="e">the exception to log</param>
public virtual void Trace(Exception e) => Log(Level.Trace, e);
/// <summary> /// <summary>
/// Sends a debug message. /// Sends a debug message.
/// Equivalent to `Log(Level.Debug, message);` /// Equivalent to `Log(Level.Debug, message);`


+ 4
- 2
IPA.Loader/Logging/StandardLogger.cs View File

@ -112,8 +112,8 @@ namespace IPA.Logging
/// <param name="cfg"></param> /// <param name="cfg"></param>
internal static void Configure(SelfConfig cfg) internal static void Configure(SelfConfig cfg)
{ {
showSourceClass = cfg.Debug.ShowCallSource;
PrintFilter = cfg.Debug.ShowDebug ? LogLevel.All : LogLevel.InfoUp;
showSourceClass = SelfConfig.Debug_.ShowCallSource_;
PrintFilter = SelfConfig.Debug_.ShowDebug_ ? LogLevel.All : LogLevel.InfoUp;
} }
private StandardLogger(StandardLogger parent, string subName) private StandardLogger(StandardLogger parent, string subName)
@ -187,6 +187,8 @@ namespace IPA.Logging
if (message == null) if (message == null)
throw new ArgumentNullException(nameof(message)); throw new ArgumentNullException(nameof(message));
if (!SelfConfig.Debug_.ShowTrace_ && level == Level.Trace) return;
// make sure that the queue isn't being cleared // make sure that the queue isn't being cleared
logWaitEvent.Wait(); logWaitEvent.Wait();
logQueue.Add(new LogMessage logQueue.Add(new LogMessage


+ 8
- 0
docs/articles/command-line.md View File

@ -33,6 +33,14 @@ Here's a quick list of what they are and what they do.
> This overrides the config settings `Debug.ShowDebug` and `Debug.ShowCallSource`. > This overrides the config settings `Debug.ShowDebug` and `Debug.ShowCallSource`.
> >
- `--trace`
> Enables trace level messages. By default, they do not ever enter the message queue, and thus cost almost nothing.
> When this or the config option is used, they are added and logged with the same rules as Debug messages.
>
> This overrides the config setting `Debug.ShowTrace`.
>
- `--mono-debug` - `--mono-debug`
> Enables the built-in Mono soft debugger engine. > Enables the built-in Mono soft debugger engine.


Loading…
Cancel
Save