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

Improve logging #5

Conversation

chilagrow
Copy link

Description

Closes #<issue_number>.

Readiness checklist

  • I added/updated unit tests (and they pass).
  • I added/updated integration/compatibility tests (and they pass).
  • I added/updated comments and checked rendering.
  • I made spot refactorings.
  • I updated user documentation.
  • I ran task all, and it passed.
  • I ensured that PR title is good enough for the changelog.
  • (for maintainers only) I set Reviewers (@FerretDB/core), Milestone (Next), Labels, Project and project's Sprint fields.
  • I marked all done items in this checklist.

if err != nil {
l.Fatal("Connection failed", zap.Error(err))
logger.Fatal("Connection failed.", zap.Error(err))
Copy link
Author

Choose a reason for hiding this comment

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

Using logger.Fatal(...) uses zap.Field appropriately like this

FATAL   ferretdb/main.go:375    Connection failed.      {"error": "some error"}

Sugared l.Fatal(...) is expected for Fatalf usage, so error displayed string concatenated and isn't friendly.

FATAL   ferretdb/main.go:375    Connection failed.{error 26 0  some error}

Comment on lines +113 to +114
redactedURL := u.Redacted()
l.Debugf("Pinging %s...", redactedURL)
Copy link

Choose a reason for hiding this comment

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

No need fro that on debug level

}

if cli.Listen.Unix != "" {
l.Debugf("--listen-unix flag is set. Ping to %s will be performed.", cli.Listen.Unix)

urls = append(urls, "mongodb://"+url.PathEscape(cli.Listen.Unix))
urls = append(urls, &url.URL{Scheme: "mongodb", Path: url.PathEscape(cli.Listen.Unix)})
Copy link
Owner

Choose a reason for hiding this comment

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

I've actually tried to implement it like that before, but unfortunately url.URL is not meant for unix socket as it escapes % from the url.PathEscape. It doesn't escape '/' though, so it's not possible to not use PathEscape function.

@chilagrow chilagrow closed this Jul 22, 2024
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.

3 participants