- add SimpleLogger class - add LogLevel enum and current_log_level which serve to show only logs with level > to it - add trace, debug, info, warning, error functions and their abbreviate form - add _print function which is in charge to print the message - the message can have timestamp and type being showed before the message [<type> ][<timestamp>]: <message> - add the possibility to let specify a file where to save the file in append mode
LoggerAddon Documentation
A comprehensive logging system for Godot that provides multiple log levels, timestamps, and file persistence.
Features
- Multiple log levels (TRACE, DEBUG, INFO, WARN, ERROR)
- Optional timestamps for each log message
- File logging with automatic directory creation
- Both full and abbreviated function names
- Configurable log filtering by level
Configuration
Inspector Properties
| Property | Type | Default | Description |
|---|---|---|---|
current_log_level |
LogLevel | DEBUG | Minimum log level to display |
enable_timestamp |
bool | true | Add timestamp to log messages |
save_log |
bool | false | Save logs to file |
folder |
String | "" | Directory for log files |
log_filename |
String | "addons/Logs/data.log" | Log file path |
Log Levels
From lowest to highest priority:
- TRACE: Detailed debugging information
- DEBUG: General debugging information
- INFO: Informational messages
- WARN: Warning messages (displayed in yellow)
- ERROR: Error messages (displayed in red)
Usage
Full Function Names
Logger.trace("Detailed trace message", variable1, variable2)
Logger.debug("Debug information", value)
Logger.info("Application started")
Logger.warning("This is a warning")
Logger.error("An error occurred", error_code)
Abbreviated Function Names
Logger.t("Trace", data)
Logger.d("Debug", data)
Logger.i("Info", data)
Logger.w("Warning", data)
Logger.e("Error", data)
Log Output Format
With timestamp:
[HH:MM:SS]|[LEVEL ]: Message content
Without timestamp:
[LEVEL ]: Message content
File Logging
When save_log is enabled:
- Logs are saved to the specified file path
- Directories are created automatically if they don't exist
- Messages are appended to the file (not overwritten)
- File operations are handled safely with error checking
Example Configuration
Logger.current_log_level = LogLevel.DEBUG
Logger.enable_timestamp = true
Logger.save_log = true
Logger.folder = "user://logs/"
Logger.log_filename = "game.log"
Tips
- Set
current_log_leveltoLogLevel.ERRORin production to reduce console spam - Use TRACE and DEBUG for development, remove them before shipping
- Combine multiple arguments in a single call for cleaner logs
- File logging automatically creates missing directories
MIT License
Copyright (c) 2025 Vincenzo Gavioli
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.