-
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
and Log.SaveOnError
is false
. These defaults are flipped otherwise. These may be set at runtime.
The assumption here is, that when you are making your game, you'll probably build is as a "Console Application" ([Your Project] right click > Properties.. > General/Project > TargetType) and when you are building for release, the TargetType will be "GUI Application" (meaning no additional console window will open).
When Log.SaveOnError
is true
, the log will be prepended to a file "log.txt" in the Core.System.UserPath
directory. The log calls made before this [and after the last error call] and the most recent error call up to a maximum of 64 (can be expanded to 512, see Preprocessor Defines) lines total will be saved. This file might be useful for user bug reports.
You can also force-save the log record to a path of your choosing yourself using Log.SaveToFile(String path)
. This behaves just like what Log.SaveOnError
does.
There are four types of logging calls, Log.Debug
, Log.Message
, Log.Warning
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.
You may choose to ignore calls to Log.Message
and Log.Warning
respectively. See Preprocessor Defines.
If you want to receive log messages as well, you can do so by using the Log.OnLine
event.