Skip to content
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

Remove globals and refactor to complete implementation of logging. #4446

Merged
merged 5 commits into from
Apr 19, 2024

Conversation

wargio
Copy link
Member

@wargio wargio commented Apr 18, 2024

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

  • Removes almost all the globals from the logging api
  • Logging C API are now thread-safe.
  • Implements colored logs and more.
  • RZ_LOG_SILLY has been removed.
  • Should be a bit faster since fprintf has been converted to fputs.
  • Renamed log.traplevel to log.abortlevel and hide it in release builds.

Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding. Apart from Doxygen - LGTM

librz/util/log.c Show resolved Hide resolved
librz/util/log.c Show resolved Hide resolved
@wargio wargio requested a review from XVilka April 18, 2024 14:51
Copy link
Member

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are at it. Could you add a simple getter for the current log level? Plugins can check it, when they print log messages.

Or, even better, add a logging function which takes the message as a string (not with vargs). Because vargs cannot be used from a few languages.

@Rot127
Copy link
Member

Rot127 commented Apr 18, 2024

Actually, if you do spent the time to add the logging API for plugins, it might be a good idea add an additional argument, where plugins can pass their name.
So the log messages can be distinguished from main Rizin.

[INFO] [Plugin] ...

librz/core/cconfig.c Outdated Show resolved Hide resolved
@wargio
Copy link
Member Author

wargio commented Apr 19, 2024

Actually, if you do spent the time to add the logging API for plugins, it might be a good idea add an additional argument, where plugins can pass their name. So the log messages can be distinguished from main Rizin.

[INFO] [Plugin] ...

tbh, there is an option which tells you the function, file and line where that occurs.

@wargio wargio merged commit 3033f62 into dev Apr 19, 2024
46 of 47 checks passed
@wargio wargio deleted the refactor-rzlog branch April 19, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants