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

Switch to a structured logger #74

Merged
merged 9 commits into from
Aug 5, 2021
Merged

Conversation

kradalby
Copy link
Collaborator

@kradalby kradalby commented Aug 5, 2021

This PR migrates from the built in Go logger to a structured logger (zerolog).

This allows us to:

  • Make loglevels user configurable
  • Add loads of trace and debug logging to help developer, but not bother users
  • Type safe fields in each log entry
  • Enforce some structure and consistency on log messages

Please note, this does not change or override Gin's logger, only the internal one.

example:
image

@kradalby kradalby marked this pull request as ready for review August 5, 2021 21:01
@kradalby kradalby mentioned this pull request Aug 5, 2021
@@ -17,7 +18,7 @@ var rootCmd = &cobra.Command{
headscale is an open source implementation of the Tailscale control server

Juan Font Alonso <[email protected]> - 2021
https://gitlab.com/juanfont/headscale`,
https://github.com/juanfont/headscale`,
Copy link
Owner

Choose a reason for hiding this comment

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

Good catch!

log.Debug().
Str("handler", "Registration").
Str("machine", m.Name).
Msg("Client is registered and we have the current NodeKey. All clear to /mSending keepaliveap")
Copy link
Owner

Choose a reason for hiding this comment

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

All clear to /mSending keepaliveap

All clear to /map

Copy link
Owner

@juanfont juanfont left a comment

Choose a reason for hiding this comment

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

This is absolutely awesome. Can you just fix the log message on /map?

@juanfont
Copy link
Owner

juanfont commented Aug 5, 2021

Actually, #75 is too important. Going to merge this immediately.

@juanfont juanfont merged commit d421c7b into juanfont:main Aug 5, 2021
@kradalby kradalby deleted the deadlock-logging branch March 2, 2022 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants