Skip to content

RSDK-13826: Do not deduplicate for debug-level loggers (or when debug is on)#5964

Open
benjirewis wants to merge 2 commits intoviamrobotics:mainfrom
benjirewis:no-debug-deduplicate
Open

RSDK-13826: Do not deduplicate for debug-level loggers (or when debug is on)#5964
benjirewis wants to merge 2 commits intoviamrobotics:mainfrom
benjirewis:no-debug-deduplicate

Conversation

@benjirewis
Copy link
Copy Markdown
Member

RSDK-13286

[aided by Claude 🤖]

What

Skips log deduplication when a logger's level is DEBUG or when viam-server is run with -debug or "debug": true.

Why

Users who enable debug logging want to see every log line. Deduplicating (squashing repeated messages) defeats the purpose of asking for verbose output.

Testing

Added TestDebugLevelNeverDeduplicates which verifies that a logger at DEBUG level emits all repeated messages, and that bumping it back to INFO re-enables deduplication. Also manually tested that various debug settings do or do not deduplicate messages as expected.

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Apr 24, 2026
@benjirewis benjirewis changed the title Do no deduplicate for debug-level loggers (or when debug is on) RSDK-13826: Do no deduplicate for debug-level loggers (or when debug is on) Apr 24, 2026
Comment thread logging/impl_test.go
logger := &impl{
name: "impl",
level: NewAtomicLevelAt(DEBUG),
level: NewAtomicLevelAt(INFO),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Needs to be INFO to deduplicate now.

Comment thread logging/impl_test.go
}

for range 4 {
logger.Info("identical message")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that an Info, Warn, or Error (in addition to Debug) log from a logger with a level set to "debug" will not be deduplicated. E.g., if I set the builtin datamanager's log level to "debug", logs of all levels from that logger will not be deduplicated.

Comment thread logging/impl.go
Comment on lines +267 to +269
// If the logger is at DEBUG level, or viam-server is run with "debug": true or
// `-debug`, never deduplicate. If a user asks for debug logs, they likely want to see
// all logs.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

or viam-server is run with "debug": true or -debug

Setting "debug": true or running with -debug is now equivalent to putting "disable_log_deduplication": true in your JSON config.

@benjirewis benjirewis changed the title RSDK-13826: Do no deduplicate for debug-level loggers (or when debug is on) RSDK-13826: Do not deduplicate for debug-level loggers (or when debug is on) Apr 24, 2026
@benjirewis benjirewis requested a review from Copilot April 24, 2026 19:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the logging deduplication behavior so that when debug logging is enabled (either via a DEBUG-level logger or global debug mode), repeated log messages are no longer squashed.

Changes:

  • Skip log deduplication in impl.Write when the logger is set to DEBUG or when GlobalLogLevel is zapcore.DebugLevel.
  • Update TestLoggingDeduplication to run with an INFO-level logger (since DEBUG no longer deduplicates).
  • Add TestDebugLevelNeverDeduplicates to validate that DEBUG-level loggers do not deduplicate and that INFO re-enables it.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
logging/impl.go Changes deduplication gating logic to disable dedup when debug logging is enabled (per-logger or global).
logging/impl_test.go Adjusts existing dedup test to INFO and adds a new test asserting DEBUG-level loggers never deduplicate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread logging/impl.go
Comment on lines +266 to +270
if imp.registry.DeduplicateLogs.Load() && !imp.neverDeduplicate &&
// If the logger is at DEBUG level, or viam-server is run with "debug": true or
// `-debug`, never deduplicate. If a user asks for debug logs, they likely want to see
// all logs.
imp.level.Get() != DEBUG && GlobalLogLevel.Level() != zapcore.DebugLevel {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks Copilot.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Apr 24, 2026
@benjirewis benjirewis requested a review from cheukt April 24, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test This pull request is marked safe to test from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants