-
Notifications
You must be signed in to change notification settings - Fork 382
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
META Improve Logging #999
Comments
@gfanton, once you come across this, could you summarize our solutions at Berty and Weshnet? I believe we had a solid approach there. In essence, we implemented multiple outputs with separate configurations, encompassing a human-readable stderr, a comprehensive machine-friendly log file with log rotation, an in-memory ring facilitating API log consumption, and a dynamic filter selection enabled by configuration. For further context, here are a few links: https://github.com/moul/zapfilter, https://github.com/berty/weshnet/tree/main/pkg/logutil. |
Quick experience return: the filtering was a pain for me because the init on mobile was complex and it was hard to make sure the config was properly used |
Good and fast library for logging I had been using on my recent projects: https://github.com/rs/zerolog |
I've also had a relatively bad experience with logs on GNO. The overflow of logs, coupled with the inability to disable or redirect them to a file, can be problematic, especially when some logs don't utilize the logger. @moul In Berty, we use zap. However, given the diverse device/platform contexts (iOS, Android, Desktop, etc.) and multiple application layers (React Native -> iOS/Java -> Golang), we had to make a system that allows multiple stream outputs with distinct configurations for each (e.g., rotation logs without filtering to files, error-only logs for the iOS/Java bridge, an ios only driver using os_log with specific formatting, and so on). Additionally, we have a custom namespace filtering system that @moul created, called moul/zapfilter, which uses pattern matching for real-time filtering. Personally, I'm not a huge fan of this approach. I believe such filtering should be user-driven, either by piping it with another application or through a subsequent search using their preferred editor. As long as we can adjust the verbosity level with separate flags, I'm okay with using this type of filtering. beside that, I think an essential first step would be to move (with a few exceptions) every
I'm not opposed to zerolog. However, even though zap might be more complex to configure, I believe it's better suited for larger projects that demand complex configurations. Moreover, zap is more widely adopted and, as a result, has broader third-party app support. |
I'll pick up this issue since I've been meaning to tackle it for some time |
Some scattered ideas for various places for improvement relating to the GnoVM I've been meaning to write for a while. Logging
Error handlingThe crucial part here is that I think we need to start creating a "class of errors" generated by Ideas:
Debugging tools
|
Based on a discussion with @piux2, we have identified a solution that addresses both the DevX and security requirements. Here are the proposed changes:
|
## Description This PR introduces log standardization across the codebase, to utilize the `slog.Logger`. Since the gno repo currently utilizes `go1.20` as the minimum version, this PR utilizes the `golang.org/x/exp/log` package. Additionally, this PR removes log level management from the TM2 config, and instead moves it into the start command. Closes #999 Thank you @gfanton for helping out with zap and simplifying the API 🙏 Special shoutout to @moul's [zapconfig](https://github.com/moul/zapconfig/tree/master), for being an inspiration on zap setup. **BREAKING CHANGE**: - the `tm2/log` logger interface has been removed, everything has been swapped to `*slog.Logger` Example of different log levels: ![cast](https://github.com/gnolang/gno/assets/16712663/2288ad98-7f72-4f05-b749-827b815b7f16) <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Signed-off-by: gfanton <[email protected]> Co-authored-by: gfanton <[email protected]> Co-authored-by: Manfred Touron <[email protected]>
## Description This PR introduces log standardization across the codebase, to utilize the `slog.Logger`. Since the gno repo currently utilizes `go1.20` as the minimum version, this PR utilizes the `golang.org/x/exp/log` package. Additionally, this PR removes log level management from the TM2 config, and instead moves it into the start command. Closes gnolang#999 Thank you @gfanton for helping out with zap and simplifying the API 🙏 Special shoutout to @moul's [zapconfig](https://github.com/moul/zapconfig/tree/master), for being an inspiration on zap setup. **BREAKING CHANGE**: - the `tm2/log` logger interface has been removed, everything has been swapped to `*slog.Logger` Example of different log levels: ![cast](https://github.com/gnolang/gno/assets/16712663/2288ad98-7f72-4f05-b749-827b815b7f16) <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Signed-off-by: gfanton <[email protected]> Co-authored-by: gfanton <[email protected]> Co-authored-by: Manfred Touron <[email protected]>
We've had quite a few chats about improving our logging system. Some things we're thinking about are:
I'm going to leave this issue open for now. It's not a top priority, but we keep coming back to it, so it's handy to have it flagged with an issue number.
The text was updated successfully, but these errors were encountered: