Skip to content

Logging

Ryan edited this page May 7, 2019 · 7 revisions

Logging Messages with SKSE

Logging can be done via the IDebugLog class accessed using #include "common/IDebugLog.h". SKSE declares a global log extern IDebugLog gLog which must first open a log to print to. Use the member function OpenRelative to do this. Afterwards, gLog can be accessed directly, or through shortcut functions such as _FATALERROR, _MESSAGE, etc. These message functions take a formatting string const char* fmt and an optional number of variadic arguments (the ellipse ...). To use these message functions, call them just like you would call printf, and the logger will take care of the rest for you. Note that due to implementation details, the logger has a maximum message length of 8192.

CommonLib Extensions

CommonLib extends SKSE logging by pushing logging messages to Visual Studio's Output window available during debug. These extensions are exposed as macros which match SKSE's native logging functions in name and signature. Because of this, access to these extensions is as simple as using #include "Logging.h". Note that Visual Studio catches debug messages from all plugins, meaning authors should take care to exclude the header in release builds so as to not clutter the output window.

Clone this wiki locally