Skip to content

Logging

Simple logger. An autoload GLogging will be created on installation. Logging methods support formatting, values won't be stringified if they are not logged.

Logging into a file is not supported. The output will be always done via print.

Compatibility

Godot Version
4.3 >= 1.5.0
4.2 >= 1.5.0
4.1 <= 1.4.1

Example

/examples/glogging/

Example output.

2023-07-04 15:57:16.242 [    INFO] [      root] ready and initialize GUI
2023-07-04 15:57:16.242 [    INFO] [      root] initialized logger root and other
2023-07-04 15:57:18.300 [   DEBUG] [      root] Demo Text!
2023-07-04 15:57:20.452 [    INFO] [      root] Demo Text!
2023-07-04 15:57:22.071 [ WARNING] [      root] Demo Text!
2023-07-04 15:57:24.606 [   ERROR] [      root] Demo Text!
2023-07-04 15:57:28.793 [CRITICAL] [      root] Demo Text!
2023-07-04 15:57:37.483 [    INFO] [   network] Demo Text!
2023-07-04 15:57:50.843 [    INFO] [       gui] Demo Text!

Interface

GLogging

res://addons/glogging/glogging.gd

Logging base class. Provides helper methods.

Properties

Name Type Description
root_logger Logger root logger object.

Constants

Name Type Value Description
LEVEL_NOTSET int 0 Logging level not set.
LEVEL_DEBUG int 10
LEVEL_INFO int 20
LEVEL_WARNING int 30
LEVEL_ERROR int 40
LEVEL_CRITICAL int 50

Methods

void debug ( Variant message, Array[Variant]=[] values ) const
log with root logger at debug level
void info ( Variant message, Array[Variant]=[] values ) const
log with root logger at info level
void warning ( Variant message, Array[Variant]=[] values ) const
log with root logger at warning level, will also display a debug warning
void error ( Variant message, Array[Variant]=[] values ) const
with root logger at error level, will also display a debug error
void critical ( Variant message, Array[Variant]=[] values ) const
log with root logger at critical level
void log ( int level, Variant message, Array[Variant]=[] values ) const
log at a custom level

GLogging.Logger

extendsRefCounted

res://addons/glogging/glogging.gd

Logger class. If not log level is set, the log level of the parent logger will be used.

Methods

Logger create_child ( String module_name, int log_level=LEVEL_NOTSET) const
create a child logger
void set_log_level ( int level )
set the log level
int log_level () const
get log level
void debug ( Variant message, Array[Variant]=[] values) const
log at debug level
void info ( Variant message, Array[Variant]=[] values) const
log at info level
void warning ( Variant message, Array[Variant]=[] values) const
log at warning level, will also display a debug warning
void error ( Variant message, Array[Variant]=[] values) const
log at error level, will also display a debug error
void critical ( Variant message, Array[Variant]=[] values) const
log at critical level
void log ( int level, Variant message, Array[Variant]=[] values) const
log at custom level

Changelog

1.5.1

  • Code improvement

1.5.0

  • Require Godot 4.2
  • Add more values to plugin.cfg