-
Notifications
You must be signed in to change notification settings - Fork 157
Logging
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 extends SKSE logging by adding file and line info to messages, as well as pushing them to Visual Studio's Output window available during debugging. 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. As such, messages are excluded from the Output window in release builds so as to not clutter the window.