Logging Interface.
- Version
- v.4 (2014-02-14)
- Author
- W. Minchin (MinchinWeb)
- Since
- MetaLibrary v.4
To make use of this library, add this you the info.nut
file of your AI:
function GetSettings() {
AddSetting({name = "Debug_Level", description = "Debug Level ", min_value = 0, max_value = 8, easy_value = 3, medium_value = 3, hard_value = 3, custom_value = 3, flags = CONFIG_INGAME});
}
This will add an option to your AI allowing users to control the debug output from your AI. You can allow this setting to be configured in-game, as it is read each time the class is called.
- Note
- There is no requirement that you use the Logging interface in your AI if you make use of MetaLibrary. You just will not see any debugging output from the library.
-
This class will work equally well as a static or a non-static class, as Debug Level is determined at each call.
Definition at line 42 of file Log.nut.
function _MinchinWeb_Log_::Error |
( |
Message |
| ) |
|
|
inlinestatic |
Output errors to the AI debug screen.
Displays the message as an Error (in red text).
Can be used as a replacement for AILog.Error()
. If not captured, errors (including calling this function) will crash your AI.
- Parameters
-
Message | message to print to AI debug screen |
Definition at line 134 of file Log.nut.
function _MinchinWeb_Log_::UpdateDebugLevel |
( |
| ) |
|
|
inlinestatic |
Looks for an AI setting for Debug Level, and set the debug level to that.
This is a bit of a failsafe. If there is no AI setting for the debug level, then a default of 3 is used.
This function will not typically need to be called directly.
- Returns
- current debug level, as per AI setting.
- See also
- _DebugLevel
Definition at line 164 of file Log.nut.
_MinchinWeb_Log_::_DebugLevel = null |
|
private |
Used to hold the current debug level.
Messages with a debug level less than or equal to the current debug level will be printed to the AI debug screen (or a sign placed, as appropriate). Others will be silently ignored.
The debug level is not designed to be set directly by the AI.
This is how I have 'translated' the various levels 1 through 7 on the AI settings to what I would expect to see on the debug screen.
- AI's
- 0 - run silently
- 1 - 'Operations' noted here
- 2 - 'normal' debugging - each step
- 3 - substeps
- 4 - most verbose (including arrays)
- 5 - including signs (but generally nothing more from the AI to the debug screen)
- Libraries
- 5 - basic
- 6 - verbose
- 7 - signs
- 8 - signs for library subfunctions
Every level beyond 1 is indented 5 spaces per higher level.
Definition at line 94 of file Log.nut.