Changes

Line 54: Line 54:     
==Mod APIs==
 
==Mod APIs==
===Logging===
  −
Your mod can write messages to the console window and log file using the monitor. For example, this code:
  −
  −
<source lang="c#">
  −
this.Monitor.Log("a trace message", LogLevel.Trace);
  −
this.Monitor.Log("a debug message", LogLevel.Debug);
  −
this.Monitor.Log("an info message", LogLevel.Info);
  −
this.Monitor.Log("a warning message", LogLevel.Warn);
  −
this.Monitor.Log("an error message", LogLevel.Error);
  −
</source>
  −
  −
will log something like this:
  −
  −
<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 DEBUG Mod Name] a debug message</span><br />
  −
<span style="color:black;">[18:00:00 INFO  Mod Name] an info message</span><br />
  −
<span style="color:darkorange;">[18:00:00 WARN  Mod Name] a warning message</span><br />
  −
<span style="color:red;">[18:00:00 ERROR Mod Name] an error message</span>
  −
</div>
  −
  −
Note that <tt>LogLevel.Trace</tt> messages won't appear in the console window by default, they'll only be written to the log file. Trace messages are for troubleshooting details that are useful when someone sends you their error log, but which the player normally doesn't need to see. (You can see trace messages in the console if you install the "SMAPI for developers" version.)
  −
   
===Reflection===
 
===Reflection===
 
SMAPI provides an API for robustly accessing fields, properties, or methods you otherwise couldn't access, such as private fields. You can use it from <tt>helper.Reflection</tt> in your entry method, or <tt>this.Helper.Reflection</tt> elsewhere in your entry class.
 
SMAPI provides an API for robustly accessing fields, properties, or methods you otherwise couldn't access, such as private fields. You can use it from <tt>helper.Reflection</tt> in your entry method, or <tt>this.Helper.Reflection</tt> elsewhere in your entry class.
translators
8,404

edits