-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add godot error messages #10
Add godot error messages #10
Conversation
Having the error code and the module name as optional parameters has the problem that the latter is dependent on the first to always be filled. This means that the module name has to be set if I want the error message. func error(message, , error_code = -1, module = default_module_name): On another topic: var output_format = "[{LVL}] [{MOD}] {ERR_MSG} {MSG}" |
Oop, yep. Missed the space. I don't think changing it to
I can optionally add the space if there is an error present. That might break some assumptions users have with how the As for the param order, I'm unsure which would be used more frequently, module or error code. When I was using the error codes, every log message had a module. But that's just my style. The main reason why I added it as the last param however, is that moving where the |
Regarding the space: It can be added inside the # Error message substitution
var error_message = error_messages.get(error_code)
if error_message != null:
output = output.replace(FORMAT_IDS.error_message, " " + error_message)
else:
output = output.replace(FORMAT_IDS.error_message, '') Regarding the parameters: |
@@ -6,6 +6,58 @@ | |||
|
|||
extends Node # Needed to work as a singleton | |||
|
|||
const error_messages = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for the purpose of this plugin, but in the long run I think it might be worth having this kind of stringification of error codes directly in the engine itself, as many users would benefit from an easy translation of error numbers to human readable strings.
Would there be use for this feature outside of Though it would make it harder to customize the format (unless a new format template is added for error messages specifically). Regarding the use of the API with the growing number of optional parameters, I share the concern. The 'module' system we designed initially feels quite awkward to me now, and I think a refactoring could be useful. The module could be a class member and there could be different LoggerModule instances for each, so you could do e.g. |
I have created an Issue #13 to discuss the modules further. So this PR can be merged ^^ |
2cd168c
to
bae6ed3
Compare
Adds option to include error codes in log functions. See README for usage. As one of the feature requests in #9.
Output for the log line
Will look like: