diff --git a/IPA.Loader/Config/SelfConfig.cs b/IPA.Loader/Config/SelfConfig.cs index d9df479e..e2fbd1ab 100644 --- a/IPA.Loader/Config/SelfConfig.cs +++ b/IPA.Loader/Config/SelfConfig.cs @@ -59,6 +59,9 @@ namespace IPA.Config CommandLineValues.Updates.AutoCheckUpdates = false; CommandLineValues.Updates.AutoUpdate = false; break; + case "--trace": + CommandLineValues.Debug.ShowTrace = true; + break; } } } @@ -118,6 +121,11 @@ namespace IPA.Config public int HideLogThreshold = 512; // LINE: ignore 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_(); diff --git a/IPA.Loader/Logging/Logger.cs b/IPA.Loader/Logging/Logger.cs index 69fd3b64..1a030c9c 100644 --- a/IPA.Loader/Logging/Logger.cs +++ b/IPA.Loader/Logging/Logger.cs @@ -56,6 +56,11 @@ namespace IPA.Logging /// None = 0, + /// + /// A trace message. These are ignored *incredibly* early. + /// + Trace = 32, + /// /// A debug message. /// @@ -98,6 +103,8 @@ namespace IPA.Logging /// None = Level.None, + TraceOnly = Level.Trace, + /// /// Only shows Debug messages. /// @@ -148,10 +155,15 @@ namespace IPA.Logging /// InfoUp = InfoOnly | NoticeUp, + /// + /// Shows all messages debug and up. + /// + DebugUp = DebugOnly | InfoUp, + /// /// Shows all messages. /// - All = DebugOnly | InfoUp, + All = TraceOnly | DebugUp, /// /// Used for when the level is undefined. @@ -173,6 +185,22 @@ namespace IPA.Logging /// the exception to log public virtual void Log(Level level, Exception e) => Log(level, e.ToString()); + /// + /// Sends a trace message. + /// Equivalent to `Log(Level.Trace, message);` + /// + /// + /// the message to log + public virtual void Trace(string message) => Log(Level.Trace, message); + + /// + /// Sends an exception as a trace message. + /// Equivalent to `Log(Level.Trace, e);` + /// + /// + /// the exception to log + public virtual void Trace(Exception e) => Log(Level.Trace, e); + /// /// Sends a debug message. /// Equivalent to `Log(Level.Debug, message);` diff --git a/IPA.Loader/Logging/StandardLogger.cs b/IPA.Loader/Logging/StandardLogger.cs index a4a80b71..18df65ee 100644 --- a/IPA.Loader/Logging/StandardLogger.cs +++ b/IPA.Loader/Logging/StandardLogger.cs @@ -112,8 +112,8 @@ namespace IPA.Logging /// 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) @@ -187,6 +187,8 @@ namespace IPA.Logging if (message == null) throw new ArgumentNullException(nameof(message)); + if (!SelfConfig.Debug_.ShowTrace_ && level == Level.Trace) return; + // make sure that the queue isn't being cleared logWaitEvent.Wait(); logQueue.Add(new LogMessage diff --git a/docs/articles/command-line.md b/docs/articles/command-line.md index 454739c1..92937647 100644 --- a/docs/articles/command-line.md +++ b/docs/articles/command-line.md @@ -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`. > +- `--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` > Enables the built-in Mono soft debugger engine.