diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI/Framework/Monitor.cs | 10 | ||||
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/StardewModdingAPI/Framework/Monitor.cs b/src/StardewModdingAPI/Framework/Monitor.cs index 33c1bbf4..3a9276a0 100644 --- a/src/StardewModdingAPI/Framework/Monitor.cs +++ b/src/StardewModdingAPI/Framework/Monitor.cs @@ -44,6 +44,9 @@ namespace StardewModdingAPI.Framework /// <summary>Whether to write anything to the console. This should be disabled if no console is available.</summary> internal bool WriteToConsole { get; set; } = true; + /// <summary>Whether to write anything to the log file. This should almost always be enabled.</summary> + internal bool WriteToFile { get; set; } = true; + /********* ** Public methods @@ -116,7 +119,7 @@ namespace StardewModdingAPI.Framework string levelStr = level.ToString().ToUpper().PadRight(Monitor.MaxLevelLength); message = $"[{DateTime.Now:HH:mm:ss} {levelStr} {source}] {message}"; - // log + // write to console if (this.WriteToConsole && (this.ShowTraceInConsole || level != LogLevel.Trace)) { this.ConsoleManager.ExclusiveWriteWithoutInterception(() => @@ -131,7 +134,10 @@ namespace StardewModdingAPI.Framework Console.WriteLine(message); }); } - this.LogFile.WriteLine(message); + + // write to log file + if (this.WriteToFile) + this.LogFile.WriteLine(message); } } } diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 91a39042..f4518e21 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -112,8 +112,10 @@ namespace StardewModdingAPI // redirect direct console output { - IMonitor monitor = Program.GetSecondaryMonitor("Console.Out"); - Program.ConsoleManager.OnLineIntercepted += line => monitor.Log(line, LogLevel.Trace); + Monitor monitor = Program.GetSecondaryMonitor("Console.Out"); + monitor.WriteToFile = false; // not useful for troubleshooting mods per discussion + if (monitor.WriteToConsole) + Program.ConsoleManager.OnLineIntercepted += line => monitor.Log(line, LogLevel.Trace); } // add warning headers |