Changes

→‎Verbose logging: add example config
Line 17: Line 17:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
will log something like this:
+
...will produce log entries with a timestamp, log level, mod name, and message:
    
<div style="font-family: monospace;">
 
<div style="font-family: monospace;">
<span style="color:#666;">[18:00:00 TRACE Mod Name] a trace message</span><br />
+
<span style="color:#666;">[18:00:00 TRACE NameOfMod] a trace message</span><br />
<span style="color:#666;">[18:00:00 DEBUG Mod Name] a debug message</span><br />
+
<span style="color:#666;">[18:00:00 DEBUG NameOfMod] a debug message</span><br />
<span style="color:black;">[18:00:00 INFO  Mod Name] an info message</span><br />
+
<span style="color:black;">[18:00:00 INFO  NameOfMod] an info message</span><br />
<span style="color:darkorange;">[18:00:00 WARN  Mod Name] a warning message</span><br />
+
<span style="color:darkorange;">[18:00:00 WARN  NameOfMod] a warning message</span><br />
<span style="color:red;">[18:00:00 ERROR Mod Name] an error message</span>
+
<span style="color:red;">[18:00:00 ERROR NameOfMod] an error message</span>
 
</div>
 
</div>
 +
 +
The text won't appear in color in the log file, but will appear in color in SMAPI console window as the game runs.
    
===Log levels===
 
===Log levels===
Line 36: Line 38:  
|-
 
|-
 
| <samp>Trace</samp>
 
| <samp>Trace</samp>
| Tracing info intended for developers, usually troubleshooting details that are useful when someone sends you their error log. Trace messages won't appear in the console window by default (unless you have the "SMAPI for developers" version), though they're always written to the log file.
+
| Tracing info intended for developers, usually low-level troubleshooting details that are useful when someone sends you their error log. Trace messages won't appear in the console window by default (unless you have the "SMAPI for developers" version), though they're always written to the log file.
 
|-
 
|-
 
| <samp>Debug</samp>
 
| <samp>Debug</samp>
| Troubleshooting info that may be relevant to the player.
+
| Troubleshooting details that may be relevant to the player.
 
|-
 
|-
 
| <samp>Info</samp>
 
| <samp>Info</samp>
Line 45: Line 47:  
|-
 
|-
 
| <samp>Warn</samp>
 
| <samp>Warn</samp>
| An issue the player should be aware of. This should be used rarely.
+
| Potential problems that the player should be aware of. This should be used rarely.
 
|-
 
|-
 
| <samp>Error</samp>
 
| <samp>Error</samp>
Line 51: Line 53:  
|-
 
|-
 
| <samp>Alert</samp>
 
| <samp>Alert</samp>
| Important information to highlight for the player when player action is needed (''e.g.,'' new version available). This should be used rarely to avoid alert fatigue.
+
| Important information to highlight for the player when player action is needed (''e.g.,'' new version available). This is mainly meant for SMAPI itself, and should almost never be used by mods.
 
|}
 
|}
   Line 61: Line 63:     
===Verbose logging===
 
===Verbose logging===
You can have messages appear in the log (and console in the ''for developers'' version) only if SMAPI's verbose logging option is enabled. This is meant for diagnostic information that's sometimes needed to troubleshoot, but doesn't need to be logged in most cases. Players can enable verbose logging by editing the <samp>smapi-internal/StardewModdingAPI.config.json</samp> file.
+
You can have messages appear in the log (and console in the ''for developers'' version) only if SMAPI's verbose logging option is enabled. This is meant for diagnostic information that's sometimes needed to troubleshoot, but doesn't need to be logged in most cases.
    
There are two ways to use it:
 
There are two ways to use it:
Line 71: Line 73:  
if (this.Monitor.IsVerbose)
 
if (this.Monitor.IsVerbose)
 
   this.Monitor("This will only appear if verbose logging is enabled.", LogLevel.Trace);
 
   this.Monitor("This will only appear if verbose logging is enabled.", LogLevel.Trace);
 +
</syntaxhighlight>
 +
 +
Players can enable verbose logging by adding your mod ID to the <samp>VerboseLogging</samp> field in the <samp>smapi-internal/StardewModdingAPI.config.json</samp> file. For example, this enables it for SMAPI and Content Patcher:
 +
<syntaxhighlight lang="js">
 +
"VerboseLogging": [ "SMAPI", "Pathoschild.ContentPatcher" ],
 
</syntaxhighlight>
 
</syntaxhighlight>
  
translators
8,437

edits