-
Notifications
You must be signed in to change notification settings - Fork 3
Log
Log is an easy way to print things out or record them.
By default, when DEBUG is defined, Log.PrintToConsole
is true
, otherwise it is false
. These may be changed at runtime.
When Log.PrintToConsole
is true
, Log
calls will be output into the console and, as long as you're building with DEBUG and use the IDE, also into the IDE's output window. So if you want to build your application as "GUI Application" you can just read the log messages from the IDE window without having an extra console window open.
But if you want a clean, seperated log, you can also build your application as "Console Application" ([Your Project] right click > Properties.. > General/Project > TargetType) and view only those calls in the extra console window. In case you also want the console logging behaviour in RELEASE, manually force Log.PrintToConsole = true;
, otherwise the console window will just be empty due to the different defaults.
You can force-save the log record to a path of your choosing using Log.SaveToFile(String path = logPath)
. logPath
is a path to log.txt
in the game's save location (System.UserPath
). Or you can call Log.ToString
to get all currently stored messages (up to a maximum of Log.RecordLength
).
There are four types of logging calls, Log.Debug
, Log.Info
, Log.Warn
and Log.Error
. Each function takes in either a String
or an Object
to log.
Log.Debug
calles are automatically ignored when not building for DEBUG and will otherwise function just like a Log.Info
call.
If you want to receive log messages as well, you can do so by using the Log.OnLine
event.
On a crash, all the recent Log
calls (up to a maximum of Log.RecordLength
) will be displayed in the crash report window (or console). This should make it easier to include this (together with Beef's default call stack and fatal error dump) in crash reports.