CORE/docs/docs/reference/logger.md

2.3 KiB

sidebar_position description
4 Your usual basic logger implementation, with some extra features.

Logger

Allows for colored output, better newlines, multiple logger levels and a large variety of placeholders usable in 'config_format'.

Signals

log_event

  • Signature: bool allowed, CoreTypes.LoggerLevel level, String origin, String message, String format \

Emitted on any log call, permitted or not.
format is set to "" when allowed is set false.

Variables

Array[CoreLoggerInstance] instances = []

:::danger[Don't call] Do not call this. ::: Keeps track of all logger instances. Unused instances will be cleaned periodically.

bool verbose_mode = false

Used to determine if running in verbose/command line mode. Makes diagnostic log messages display correctly (workaround for Godot's ANSI true color limitation).

Functions

void _log(CoreTypes.LoggerLevel level, String origin, String message)

:::danger[Don't call] Do not call this. ::: The main logging function that does the heavy lifting.

void diag(String origin, String message)

Prints a diagnostic message.

void verb(String origin, String message)

Prints a verbose message.

void info(String origin, String message)

Prints an informational message.

void warn(String origin, String message)

Prints a warning message.

void error(String origin, String message)

Prints an error message.

void crash(String origin, String message, bool framework_crash = false)

:::note[Awaiting required] Using the await keyword is required for this function. ::: :::danger Don't set framework_crash to true, thanks! ::: Handles crashes. Will terminate your game/application immediately.

bool is_level_allowed(CoreTypes.LoggerLevel level)

Checks if the specified log level is allowed by the current configuration.

CoreLoggerInstance get_instance(String origin, Object parent)

Returns a CoreLoggerInstance, which is a fancy word meaning you don't need to pass origin every time you want to log something.