Changes

m
Text replacement - "tt>" to "samp>"
Line 1: Line 1:  
{{../../header}}
 
{{../../header}}
   −
The monitor API, available through <tt>this.Monitor</tt> in your mod class, mainly lets you write messages to the console window and log file.
+
The monitor API, available through <samp>this.Monitor</samp> in your mod class, mainly lets you write messages to the console window and log file.
    
==Logging==
 
==Logging==
 
===Overview===
 
===Overview===
You can log messages by calling <tt>this.Monitor.Log</tt> with a string message and a log level. These messages will appear in the SMAPI console and log file.
+
You can log messages by calling <samp>this.Monitor.Log</samp> with a string message and a log level. These messages will appear in the SMAPI console and log file.
    
For example, this code:
 
For example, this code:
Line 28: Line 28:     
===Log levels===
 
===Log levels===
The log level is ''semantic'', meaning that the level itself conveys information (a <tt>Trace</tt> message means something different from an <tt>Error</tt> message). You should use the log level that's closest to your message's purpose:
+
The log level is ''semantic'', meaning that the level itself conveys information (a <samp>Trace</samp> message means something different from an <samp>Error</samp> message). You should use the log level that's closest to your message's purpose:
    
{| class="wikitable"
 
{| class="wikitable"
Line 35: Line 35:  
! purpose
 
! purpose
 
|-
 
|-
| <tt>Trace</tt>
+
| <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 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.
 
|-
 
|-
| <tt>Debug</tt>
+
| <samp>Debug</samp>
 
| Troubleshooting info that may be relevant to the player.
 
| Troubleshooting info that may be relevant to the player.
 
|-
 
|-
| <tt>Info</tt>
+
| <samp>Info</samp>
 
| Info relevant to the player. This should be used judiciously.
 
| Info relevant to the player. This should be used judiciously.
 
|-
 
|-
| <tt>Warn</tt>
+
| <samp>Warn</samp>
 
| An issue the player should be aware of. This should be used rarely.
 
| An issue the player should be aware of. This should be used rarely.
 
|-
 
|-
| <tt>Error</tt>
+
| <samp>Error</samp>
 
| A message indicating something went wrong.
 
| A message indicating something went wrong.
 
|-
 
|-
| <tt>Alert</tt>
+
| <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 should be used rarely to avoid alert fatigue.
 
|}
 
|}
    
===Log once===
 
===Log once===
The <tt>LogOnce</tt> method lets you log a message just [[#Overview|like the above]], but only once per game launch. For example, you can use it to show a compatibility warning for an API call:
+
The <samp>LogOnce</samp> method lets you log a message just [[#Overview|like the above]], but only once per game launch. For example, you can use it to show a compatibility warning for an API call:
 
<syntaxhighlight lang="c#">
 
<syntaxhighlight lang="c#">
 
this.Monitor.LogOnce("Some Mod Name used the deprecated X API.", LogLevel.Warn);
 
this.Monitor.LogOnce("Some Mod Name used the deprecated X API.", LogLevel.Warn);
Line 61: Line 61:     
===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 <tt>smapi-internal/StardewModdingAPI.config.json</tt> 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. Players can enable verbose logging by editing the <samp>smapi-internal/StardewModdingAPI.config.json</samp> file.
    
There are two ways to use it:
 
There are two ways to use it:
105,955

edits