summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Monitor.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-09-07 13:06:27 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-09-07 13:06:27 -0400
commit5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83 (patch)
tree0a42305174eb84561a584549cd685c5e95670f36 /src/SMAPI/Framework/Monitor.cs
parent8da88b8fe5b41739c5cd0df3280b9770fc7f10a4 (diff)
parentf9fac11028354f15d786d5b854608edb10716f79 (diff)
downloadSMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.gz
SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.tar.bz2
SMAPI-5e43bdbf5cd6dbab36c25287c85d42ccfeea2c83.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Monitor.cs')
-rw-r--r--src/SMAPI/Framework/Monitor.cs32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/SMAPI/Framework/Monitor.cs b/src/SMAPI/Framework/Monitor.cs
index 44eeabe6..533420a5 100644
--- a/src/SMAPI/Framework/Monitor.cs
+++ b/src/SMAPI/Framework/Monitor.cs
@@ -18,8 +18,8 @@ namespace StardewModdingAPI.Framework
/// <summary>Handles writing text to the console.</summary>
private readonly IConsoleWriter ConsoleWriter;
- /// <summary>Manages access to the console output.</summary>
- private readonly ConsoleInterceptionManager ConsoleInterceptor;
+ /// <summary>Prefixing a message with this character indicates that the console interceptor should write the string without intercepting it. (The character itself is not written.)</summary>
+ private readonly char IgnoreChar;
/// <summary>The log file to which to write messages.</summary>
private readonly LogFileManager LogFile;
@@ -34,7 +34,7 @@ namespace StardewModdingAPI.Framework
/*********
** Accessors
*********/
- /// <summary>Whether verbose logging is enabled. This enables more detailed diagnostic messages than are normally needed.</summary>
+ /// <inheritdoc />
public bool IsVerbose { get; }
/// <summary>Whether to show the full log stamps (with time/level/logger) in the console. If false, shows a simplified stamp with only the logger.</summary>
@@ -52,11 +52,11 @@ namespace StardewModdingAPI.Framework
*********/
/// <summary>Construct an instance.</summary>
/// <param name="source">The name of the module which logs messages using this instance.</param>
- /// <param name="consoleInterceptor">Intercepts access to the console output.</param>
+ /// <param name="ignoreChar">A character which indicates the message should not be intercepted if it appears as the first character of a string written to the console. The character itself is not logged in that case.</param>
/// <param name="logFile">The log file to which to write messages.</param>
/// <param name="colorConfig">The colors to use for text written to the SMAPI console.</param>
/// <param name="isVerbose">Whether verbose logging is enabled. This enables more detailed diagnostic messages than are normally needed.</param>
- public Monitor(string source, ConsoleInterceptionManager consoleInterceptor, LogFileManager logFile, ColorSchemeConfig colorConfig, bool isVerbose)
+ public Monitor(string source, char ignoreChar, LogFileManager logFile, ColorSchemeConfig colorConfig, bool isVerbose)
{
// validate
if (string.IsNullOrWhiteSpace(source))
@@ -66,29 +66,24 @@ namespace StardewModdingAPI.Framework
this.Source = source;
this.LogFile = logFile ?? throw new ArgumentNullException(nameof(logFile), "The log file manager cannot be null.");
this.ConsoleWriter = new ColorfulConsoleWriter(Constants.Platform, colorConfig);
- this.ConsoleInterceptor = consoleInterceptor;
+ this.IgnoreChar = ignoreChar;
this.IsVerbose = isVerbose;
}
- /// <summary>Log a message for the player or developer.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="level">The log severity level.</param>
+ /// <inheritdoc />
public void Log(string message, LogLevel level = LogLevel.Trace)
{
this.LogImpl(this.Source, message, (ConsoleLogLevel)level);
}
- /// <summary>Log a message for the player or developer, but only if it hasn't already been logged since the last game launch.</summary>
- /// <param name="message">The message to log.</param>
- /// <param name="level">The log severity level.</param>
+ /// <inheritdoc />
public void LogOnce(string message, LogLevel level = LogLevel.Trace)
{
if (this.LogOnceCache.Add($"{message}|{level}"))
this.LogImpl(this.Source, message, (ConsoleLogLevel)level);
}
- /// <summary>Log a message that only appears when <see cref="IMonitor.IsVerbose"/> is enabled.</summary>
- /// <param name="message">The message to log.</param>
+ /// <inheritdoc />
public void VerboseLog(string message)
{
if (this.IsVerbose)
@@ -99,7 +94,7 @@ namespace StardewModdingAPI.Framework
internal void Newline()
{
if (this.WriteToConsole)
- this.ConsoleInterceptor.ExclusiveWriteWithoutInterception(Console.WriteLine);
+ Console.WriteLine();
this.LogFile.WriteLine("");
}
@@ -136,12 +131,7 @@ namespace StardewModdingAPI.Framework
// write to console
if (this.WriteToConsole && (this.ShowTraceInConsole || level != ConsoleLogLevel.Trace))
- {
- this.ConsoleInterceptor.ExclusiveWriteWithoutInterception(() =>
- {
- this.ConsoleWriter.WriteLine(consoleMessage, level);
- });
- }
+ this.ConsoleWriter.WriteLine(this.IgnoreChar + consoleMessage, level);
// write to log file
this.LogFile.WriteLine(fullMessage);