-
Notifications
You must be signed in to change notification settings - Fork 27
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
refactor: ♻️ Logging + ✨ Store Logs #205
Conversation
LogManager
and LogEntry
Class
Oh and I still need to fix this:
|
I was thinking the log funcs would be moved to And that the class would follow the standard of other API classes, ie. Note: The current |
I've looked over this PR's code in more detail and I have some notes. There are still logging methods in How come you've used a class instance for LogManager? Why not use it with static methods, like other API methods do? Then you can log things with Generally I think we should keep the You've used ModLoaderStore to store a class instance, but it's not intended to be used that way. It's meant to be a simple data store, partly to fix using local vars in ModLoader (see #161 + #172), but also to fix the issue of static class methods being unable to save data to their own class's local variables (because that class hasn't been instanced). So now instead, they can store data to ModLoaderStore. In this case, ModLoaderStore lets you keep track of any logged messages, via |
I will rework this to account for #153. |
LogManager
and LogEntry
ClassMoved most of the logging logic from `ModLoaderUtils` into `LogManager`. New `LogEntry` Class to store log message info. Added log storing in `LogManager`. works towards GodotModding#140
Based on the discussion in GodotModding#153 - Some compromises had to be done to prevent cyclic reference errors. No `ModLoaderUtils` functions could be used.
Had to copy the required utility functions into the setup script, because `ModLoaderUtils` depends now on other Classes that don't get loaded.
With that the ModLoaderLog Class is fully independed and can be loaded in the setup script.
accidentally removed the `log_` from the deprecation message and `log_debug_json_print`.
There tradeoffs for using the existing ModLoader Classes in the setup script are to big. So the required functions where moved into the *setup/* dir.
Should this PR be called "Logging Refactor", instead of "store logged messages"? Just thinking of the commit message which is set automatically from the PR title |
good point |
Added `time_stamp` to `ModLoaderLogEntry` and instead of saving the `time` string in `time_stamps` the same log entries are now stored in `stack`. Added `ModLoaderLogCompare` inner class, allowing to call the custom sort function.
To prevent some of the duplications
to match the other funcs
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.
only minor things.
very nice work 🚀
Added description for `ignored_mod_names_in_log` in `ModLoaderStore` and removed the `;` in the `_rotate_log_file()` comment.
Logging refactor
ModLoaderLog
).Resource
for log entriesModLoaderLogEntry
get_all_as_resource_array()
get_all_as_string_array()
get_by_mod_as_resource_array(mod_name: String)
get_by_mod_as_string_array(mod_name: String)
get_by_type_as_resource_array(type: String)
get_by_type_as_string_array(type: String)
Edit (Darkly77): This PR also introduces the feature of storing logged messages (via
_store_log
), which gives purpose to the methods listed above.Todos
ModLoaderLog
_write_to_log_file
_rotate_log_file
_clear_old_log_backups
_is_mod_name_ignored
_get_verbosity
_loader_log
_get_time_string
_get_date_string
_get_date_time_string
ModLoaderLog
and leavedeprecation()
funclog_fatal
->ModLoaderLog.fatal
log_error
->ModLoaderLog.error
log_warning
->ModLoaderLog.warning
log_info
->ModLoaderLog.info
log_success
->ModLoaderLog.success
log_debug
->ModLoaderLog.debug
log_debug_json_print
->ModLoaderLog.debug_json_print
ignored_mod_names_in_log
toml_options
inModLoaderStore
and options_profile.gdget_mod_config()
in config.gd line 73 and 75get_all_as_resource()
get_all_as_string()
get_by_mod_as_resource(mod_name: String)
get_by_mod_as_string(mod_name: String)
get_by_type_as_resource(type: String)
get_by_type_as_string(type: String)
get_by_mod(mod_name: String)
Test Mod
KANA-LogViewer.zip
Related Issues