build+lnd+docs: start using slog and add commit_hash to log lines#9314
build+lnd+docs: start using slog and add commit_hash to log lines#9314guggero merged 13 commits intolightningnetwork:masterfrom
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 |
guggero
left a comment
There was a problem hiding this comment.
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.
ellemouton
left a comment
There was a problem hiding this comment.
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).
guggero
left a comment
There was a problem hiding this comment.
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.
bhandras
left a comment
There was a problem hiding this comment.
LGTM, very nice work! 🥇
This PR does a few things:
llllinter implementation that ignores log lines.llllinter exception for log lines.--logging.build-infooption 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 :)Mainfunction to add build info to its context & use structured logging for all its logs.Example: