Conversation
sukunrt
approved these changes
Aug 20, 2025
Comment on lines
+31
to
+44
| ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr { | ||
| if a.Key == slog.TimeKey { | ||
| // ipfs go-log uses "ts" for time | ||
| a.Key = "ts" | ||
| } else if a.Key == slog.LevelKey { | ||
| // ipfs go-log uses lowercase level names | ||
| if lvl, ok := a.Value.Any().(slog.Level); ok { | ||
| if s, ok := lvlToLower[lvl]; ok { | ||
| a.Value = s | ||
| } | ||
| } | ||
| } | ||
| return a | ||
| }, |
Collaborator
Author
There was a problem hiding this comment.
What is this? The change in key and values? I want to keep this the same if users are already processing the logs (I expect some ipfs users are)
| @@ -1,25 +1,54 @@ | |||
| package canonicallog | |||
Member
There was a problem hiding this comment.
Not needed in this PR, but should we just remove this package?
Collaborator
Author
There was a problem hiding this comment.
Maybe. I'm not sure if anyone is using this. The original idea behind this was to allow connecting libp2p applications to things like fail2ban via the logger. I'd leave it unless there's a good reason to remove it.
bb6736f to
947b0a8
Compare
This was referenced Oct 25, 2025
lidel
added a commit
that referenced
this pull request
Oct 25, 2025
#3364 migrated from zap to slog but accidentally changed the log level for http.Server.ErrorLog from implicit INFO to explicit ERROR. This caused client EOF and TLS handshake errors to spam error logs and stdout in apps which log only ERROR by default. These http.Server errors (client EOFs, TLS handshake failures from clients with naive TLS implementations, connection timeouts from clients that abort early) are normal operational noise, not actual server errors. Using LevelDebug: - matches semantic meaning (similar to existing connection timeout logs) - respects user's configured threshold (default ERROR filters them out) - allows users to enable for debugging via log level configuration Fixes ipfs/kubo#11027 Fixes ipfs/kubo#11033
This was referenced Oct 26, 2025
lidel
added a commit
that referenced
this pull request
Oct 27, 2025
The migration to slog in #3364 broke go-log's ability to adjust subsystem log levels at runtime via SetLogLevel() and control output formatting (colors, json). This was a key debugging feature that allowed changing log verbosity without restarting daemons. This fix detects go-log's slog bridge via duck typing and uses it when available, restoring dynamic level control and unified formatting. When go-log isn't present, gologshim falls back to standalone slog handlers as before. The lazy handler pattern solves initialization order issues where package-level loggers are created before go-log's bridge is installed. Users just need to update to this version of go-libp2p and go-log with ipfs/go-log#176 - no code changes or init() hacks required. Prerequisite for addressing ipfs/kubo#11035
lidel
added a commit
to ipfs/kubo
that referenced
this pull request
Oct 28, 2025
update go-log to v2.8.3-0.20251027235339-5fe47a4191be (feat/slog-interop) update go-libp2p to v0.44.1-0.20251027235033-ea2c010ece2d (feat/gologshim-use-slog-default) these changes restore dynamic log level control and tail for go-libp2p subsystems after the migration to slog, fixing the regression introduced in libp2p/go-libp2p#3364 Fixes #11035
6 tasks
MarcoPolo
pushed a commit
that referenced
this pull request
Oct 28, 2025
#3364 migrated from zap to slog but accidentally changed the log level for http.Server.ErrorLog from implicit INFO to explicit ERROR. This caused client EOF and TLS handshake errors to spam error logs and stdout in apps which log only ERROR by default. These http.Server errors (client EOFs, TLS handshake failures from clients with naive TLS implementations, connection timeouts from clients that abort early) are normal operational noise, not actual server errors. Using LevelDebug: - matches semantic meaning (similar to existing connection timeout logs) - respects user's configured threshold (default ERROR filters them out) - allows users to enable for debugging via log level configuration Fixes ipfs/kubo#11027 Fixes ipfs/kubo#11033
lidel
added a commit
to ipfs/kubo
that referenced
this pull request
Nov 6, 2025
…11039) This fix restores dynamic log level control and tail for go-libp2p loggers Updated to: https://github.com/libp2p/go-libp2p/releases/tag/v0.45.0 https://github.com/ipfs/go-log/releases/tag/v2.9.0 these changes restore dynamic log level control and tail for go-libp2p subsystems after the migration to slog, fixing the regression introduced in libp2p/go-libp2p#3364 Fixes #11035 For details why and how, see explainer in https://github.com/ipfs/go-log/releases/tag/v2.9.0
lidel
added a commit
that referenced
this pull request
Nov 11, 2025
Pre-v0.44 (Working State): PR #2915 deliberately downgraded all pion logs to Debug level because "Pion logs are too noisy and have invalid log levels". This worked correctly for ~1 year without issues. v0.44.0 (Regression): PR #3364 migrated from go-log/v2 to log/slog but accidentally reverted the pion log level downgrade. The migration kept the comment claiming logs were downgraded but changed the implementation to log Error/Warn/Info at their face values, causing routine connection events to spam error logs. Similar to PR #3413 which fixed this issue for websocket transport, WebRTC transport needs the same treatment. Pion logs client disconnects, protocol mismatches, and state races as ERROR/WARN, but these are normal operational noise from a service perspective, not actual errors requiring operator attention. This restores PR #2915 behavior: downgrade all pion logs to Debug level. Fixes ipfs/kubo#11053
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #3362
This is the first step in a larger refactor to be able to pass in a custom slog down to all components and get rid of the global logger.
Also removes the ipfs/go-log dependency with a gologshim. It makes slog behave close enough to ipfs/go-log with respect to environment variables. Users who are parsing the text version will notice differences, but the JSON version is identical except the caller source location key.
Users can use gologshim from go-libp2p to remove their dependency on ipfs/go-log and migrate to slog as well.
The patch is straightforward if not large. The general rules are:
The most interesting thing to review here is likely the shim itself. But a once over on the log changes would be appreciated.