- add caller script in print - add filters to blacklist or whitelist script logs to be shown - add timer to check performance easily
2.8 KiB
SimpleLogger
Lightweight logging system for Godot 4.5+
Features
- 5 log levels (TRACE, DEBUG, INFO, WARN, ERROR)
- Caller script tracking
- Script filtering (blacklist/whitelist)
- Performance profiling
- Optional file persistence
- Configurable timestamps and separators
Quick Start
Log.i("Player spawned")
Log.d("Health:", player.health, "Position:", player.position)
Log.e("Failed to load resource", path)
Output:
[12:34:56][player ][INFO ]: Player spawned
[12:34:56][player ][DEBUG ]: Health: 100 Position: (0, 0)
[12:34:56][resource_load][ERROR ]: Failed to load resource res://missing.png
API
Log Levels
| Full | Short | Use case |
|---|---|---|
trace() |
t() |
Granular debugging |
debug() |
d() |
Development info |
info() |
i() |
General events |
warning() |
w() |
Potential issues |
error() |
e() |
Failures |
Filtering
Log.mute("chunk_generator.gd")
Log.unmute("chunk_generator.gd")
Log.set_blacklist(["map.gd", "noise.gd"])
Log.set_whitelist(["player.gd", "enemy.gd"])
Log.clear_filters()
Performance
Log.time_start("pathfinding")
# ... code ...
Log.time_end("pathfinding")
# Output: [DEBUG ]: PERF pathfinding 12.34ms
Separator
Log.set_separator(" | ")
Log.set_separator(" -> ", true) # one-time only
Properties
| Property | Default | Description |
|---|---|---|
current_log_level |
DEBUG | Minimum level to display |
enable_timestamp |
true | Show timestamps |
enable_caller |
true | Show calling script |
save_log |
false | Write to file |
filter_mode |
BLACKLIST | Filter behavior |
folder |
"" | Log directory |
log_filename |
"addons/Logs/data.log" | Log file path |
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.