Godot-Log
Simple in-game logger for Godot 4.0.
Features
- Installed as plugin.
- Singleton Log.
- Write to log file.
- Disable log levels.
- Custom log levels.
Installation:
- Clone or download this repository to
addonsfolder. - Enable
Godot Login Plugins. - Add
LogOutputnode to the scene. - 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-2023 Mansur Isaev and contributors
Unless otherwise specified, files in this repository are licensed under the MIT license. See LICENSE.md for more information.
