godotengine / godotengine/godot
Logger does not behave as documented.
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
It would seem this never worked as intended? Issue found in all versions:
- v4.5.stable.official [876b29033]
- v4.6.stable.official [89cea1439]
- v4.6.2.stable.official [71f334935]
- v4.7.beta2.official [777579205]
### System information
Godot v4.7.beta2 - Fedora Linux 44 (KDE Plasma Desktop Edition) on Wayland - Wayland display driver, Multi-window, 3 monitors - OpenGL 3 (Compatibility) - Mesa Intel(R) Iris(R) Xe Graphics (TGL GT2) - 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz (8 threads) - 62.52 GiB memory - PulseAudio (44100 Hz, Stereo/mono)
### Issue description
When using the Logger `_log_error` function the input parameters don't contain information that would be expected or as documented (https://docs.godotengine.org/en/stable/tutorials/scripting/logging.html).
When testing the functionality with the `push_error` function, the function gets passed these values in the input parameters:
- **function**: _push_error_ - should this really contain name of the push_error/push_warning function, not the one that it was called from?
- **file**: _core/variant/variant_utility.cpp_ - shouldn't this be the script file? This is the value of the parameter is always this.
- **line**: _1023_ - Definitely no the correct line in the script.
- **code**: _TEST ERROR_ - This is the text put as input in `push_error`. This doesn't seem what it should be?
- **rationale**: - This is always empty, according to documentation this should contain the error message, yet that is in the **code** parameter.
- **editor_notify**: _false_ - Not sure what this does?
- **error_type**: _0_ - This seems to be correct.
- **script_backtraces**: _[GDScript backtrace (most recent call first): [0] _ready (res://test.gd:9)]_ - This seems to be correct.
### Steps to reproduce
1. Create a logger.
2. Hook it up `OS.add_logger`
3. Call push_error or push_warning
### Minimal reproduction project (MRP)
[logger-bug.zip](https://github.com/user-attachments/files/28103549/logger-bug.zip)
Contributor guide
Research direction
Start by running the linked minimal reproduction project and compare the Logger _log_error parameters from push_error and push_warning with the logging documentation. Trace the OS.add_logger and Logger entry points to determine whether the implementation or documentation is incorrect; done means the reported fields and documented behavior agree, with regression coverage where appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools, observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100