MinchinWeb's MetaLibrary  v.9 Library functions of OpenTTD AI writers.
_MinchinWeb_Log_ Class Reference

Logging Interface. More...

## Public Member Functions

function GetVersion ()

function GetRevision ()

function GetDate ()

function GetName ()

## Static Public Member Functions

function Note (Message, Level=3)
Output messages to the AI debug screen. Displays the message if the Debug level is set high enough. More...

function Warning (Message)
Output warnings to the AI debug screen. More...

function Error (Message)
Output errors to the AI debug screen. More...

function Sign (Tile, Message, Level=5)
Prints a message on a sign. More...

function PrintDebugLevel ()
Prints the current debug level to the AI debug screen. More...

function UpdateDebugLevel ()
Looks for an AI setting for Debug Level, and set the debug level to that. More...

## Private Member Functions

function constructor ()

## Private Attributes

_DebugLevel = null

## Detailed Description

Logging Interface.

Version
v.4 (2014-02-14)
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.

## Member Function Documentation

 function _MinchinWeb_Log_::constructor ( )
inlineprivate

Does nothing

Definition at line 99 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.

 _MinchinWeb_Log_::GetDate ( )
inline
Returns
the date of the last update to the Logging Interface

Definition at line 62 of file Log.nut.

 _MinchinWeb_Log_::GetName ( )
inline
Returns
the name of the Logging Interface

Definition at line 63 of file Log.nut.

 _MinchinWeb_Log_::GetRevision ( )
inline
Returns
The revision (as per svn) of the last update to the Logging Interface.
Note
This has been changed with the move to git. On files updated since the move to git, this will be of the form YYMMDD.

Definition at line 61 of file Log.nut.

 _MinchinWeb_Log_::GetVersion ( )
inline
Returns
current version of the Logging Interface

Definition at line 60 of file Log.nut.

 function _MinchinWeb_Log_::Note ( Message , Level = 3 )
static

Output messages to the AI debug screen. Displays the message if the Debug level is set high enough.

Can be used as a replacement for AILog.Info()

Parameters
 Message message to print to AI debug screen Level required minimum level to print message (default is 3)

Definition at line 175 of file Log.nut.

 function _MinchinWeb_Log_::PrintDebugLevel ( )
static

Prints the current debug level to the AI debug screen.

Returns
nothing

Definition at line 192 of file Log.nut.

 function _MinchinWeb_Log_::Sign ( Tile , Message , Level = 5 )
static

Prints a message on a sign.

Parameters
 Tile tile to place the sign on (as an AITile object) Message message to print on the sign Level required minimum level to place tile (default is 5)

Definition at line 186 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.

 function _MinchinWeb_Log_::Warning ( Message )
inlinestatic

Output warnings to the AI debug screen.

Displays the message as a Warning (in yellow text).

Can be used as a replacement for AILog.Warning()

Parameters
 Message message to print to AI debug screen

Definition at line 121 of file Log.nut.

## Member Data Documentation

 _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.

The documentation for this class was generated from the following file: