summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/Monitor.cs25
-rw-r--r--src/SMAPI/Program.cs3
2 files changed, 25 insertions, 3 deletions
diff --git a/src/SMAPI/Framework/Monitor.cs b/src/SMAPI/Framework/Monitor.cs
index a76afc3c..b65932b2 100644
--- a/src/SMAPI/Framework/Monitor.cs
+++ b/src/SMAPI/Framework/Monitor.cs
@@ -100,6 +100,17 @@ namespace StardewModdingAPI.Framework
this.LogFile.WriteLine("");
}
+ /// <summary>Writes user input to the log file.</summary>
+ /// <param name="input">The input to write.</param>
+ internal void LogUserInputToFile(string input)
+ {
+ if (this.WriteToFile)
+ {
+ string prefix = this.GenerateMessagePrefix(this.Source, LogLevel.Info);
+ this.LogFile.WriteLine($"{prefix} $>{input}");
+ }
+ }
+
/*********
** Private methods
@@ -120,9 +131,8 @@ namespace StardewModdingAPI.Framework
private void LogImpl(string source, string message, LogLevel level, ConsoleColor color, ConsoleColor? background = null)
{
// generate message
- string levelStr = level.ToString().ToUpper().PadRight(Monitor.MaxLevelLength);
-
- string fullMessage = $"[{DateTime.Now:HH:mm:ss} {levelStr} {source}] {message}";
+ string prefix = this.GenerateMessagePrefix(source, level);
+ string fullMessage = $"{prefix} {message}";
string consoleMessage = this.ShowFullStampInConsole ? fullMessage : $"[{source}] {message}";
// write to console
@@ -148,6 +158,15 @@ namespace StardewModdingAPI.Framework
this.LogFile.WriteLine(fullMessage);
}
+ /// <summary>Generates a message prefix for the current time.</summary>
+ /// <param name="source">The name of the mod logging the message.</param>
+ /// <param name="level">The log level.</param>
+ private string GenerateMessagePrefix(string source, LogLevel level)
+ {
+ string levelStr = level.ToString().ToUpper().PadRight(Monitor.MaxLevelLength);
+ return $"[{DateTime.Now:HH:mm:ss} {levelStr} {source}]";
+ }
+
/// <summary>Get the color scheme to use for the current console.</summary>
/// <param name="colorScheme">The console color scheme to use.</param>
private static IDictionary<LogLevel, ConsoleColor> GetConsoleColorScheme(MonitorColorScheme colorScheme)
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index 9789cf85..73e8bb07 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -448,6 +448,9 @@ namespace StardewModdingAPI
if (string.IsNullOrWhiteSpace(input))
continue;
+ // write input to log file
+ this.Monitor.LogUserInputToFile(input);
+
// parse input
try
{