-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
build+lnd+docs: start using slog and add commit_hash to log lines #9314
Conversation
Important Review skippedAuto reviews are limited to specific labels. 🏷️ Labels to auto review (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
3d20b6a
to
aba4afd
Compare
7f5afd3
to
984988b
Compare
damn - looks like the linter exclusion rule only works for single-line logs... gonna see if i can write a linter plugin |
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.
Very nice! The age of structured logs has finally arrived 🚀
In this commit, we copy the implementation of the golangci-lint lll linter which we currently use in our CI flow during the `make lint` check. This commit copies the code mostly as is (the only exception being the line which trims white space before checking if a line starts with "import"), and formats it to fit our codebase guidelines. A test is also added so that we can be sure that the following commits which adjust the implementation have the intended results. The custom linter is put into its own module as this is requied by the `golangci-lint custom` when building the custom linter binary which includes the plugin.
This commit introduces the `LLPlugin` type and converts the existing lll code such that the LLPlugin implements the register.LinterPlugin interface. This will allow us to plug it into golangci-linter as a plugin.
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.
Thanks @guggero 🙏
I've updated the PR with a custom lll
linter implementation (let me know if you would prefer if I moved it to its own PR).
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.
Two suggestions, otherwise LGTM 🎉
Super nice features 💯
This commit adds a feature to our custom lll linter which will ignore log lines (both single and multi-lined log lines) for the lll linter.
Add this file both to the main LND directory so that devs can use it for local linter runs and also add it to the `tools` directory so that the docker environment used to run the linter in CI has access to it. A custom linter binary can be built via `golangci-lint custom`. This will pull in and register all the plugins listed in the new config file when building the new binary. The new binary can then be run using `custom-gcl run`.
Find and replace all nolint instances refering to the `lll` linter and replace with `ll` which is the name of our custom version of the `lll` linter which can be used to ignore log lines during linting. The next commit will do the configuration of the custom linter and disable the default one.
It can be disabled via the new `logging.no-commit-hash` config option.
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.
LGTM, very nice work! 🥇
This PR does a few things:
lll
linter implementation that ignores log lines.lll
linter exception for log lines.--logging.build-info
option which can be used to toggle if build info (currently only a commit hash fingerprint) should be included in log lines. NOTE: default is on for prod and off fordev
. Keep this in mind when testing :)Main
function to add build info to its context & use structured logging for all its logs.Example: