godot-logger icon indicating copy to clipboard operation
godot-logger copied to clipboard

Simple in-game logger for Godot 4.0

trafficstars

Godot-Log

Simple in-game logger for Godot 4.3.

Features

  • Installed as plugin.
  • Static access to the Log.
  • Writing a log to a file.
  • Enable/Disable log levels.
  • Custom log levels.
  • Managing logging settings in ProjectSettings.
  • Customizing message output formatting.

Installation:

  1. git clone this repository to addons folder.
  2. Enable Godot Log in Plugins.
  3. Add LogOutput node to the scene.
  4. Profit.

Usage:

Calling default levels:

Log.info(text)
Log.debug(text)
Log.warning(text)
Log.error(text)
Log.fatal(text)

Create a custom log level:

# main.gd
const CUSTOM = Log.MAX << 1 # Bitwise left shift the MAX value for a custom level.

func _ready() -> void:
	Log.add_level(CUSTOM, "Level Name")

Calling the custom level:

Log.message(CUSTOM, "Something happened")

Disable log level:

Log.set_level(Log.INFO, false) # Disable built-in level.
Log.set_level(CUSTOM, false) # Disable custom level.

Enable log level:

Log.set_level(Log.DEBUG, true) # Enable built-in level.
Log.set_level(CUSTOM, true) # Enable custom level.

License

Copyright (c) 2020-2024 Mansur Isaev and contributors

Unless otherwise specified, files in this repository are licensed under the MIT license. See LICENSE.md for more information.