Skip to content

logx: record Scoped components as a dotted attribute - #2

Merged
unknwon merged 1 commit into
mainfrom
logx-component-attr
Nov 16, 2026
Merged

unknwon merged 1 commit into
mainfrom
logx-component-attr

Conversation

@unknwon

@unknwon unknwon commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Logger.Scoped now records the component as a component attribute (logx.ComponentKey) instead of prefixing the message with [name] .

  • Log explorers can filter, facet and group by component directly, and the message stays the same across components.
  • Nested scopes join with dots in one attribute: Scoped("db").Scoped("gorm") logs "component":"db.gorm", so a prefix match selects a subtree.
  • The attribute stays at the top level even when Scoped is called after WithGroup, and With/WithGroup calls made in between are kept.

Breaking change: messages no longer carry the [name] prefix. Handlers that want the old look can render the component attribute themselves, which gogs does for its text sinks.

Scoped now sets a "component" attribute instead of prefixing the
message, so log explorers can filter and group by component. Nested
scopes join with dots, e.g., "db.gorm", in a single attribute that
stays out of groups.
@unknwon
unknwon merged commit bb25d45 into main Nov 16, 2026
4 checks passed
@unknwon
unknwon deleted the logx-component-attr branch November 16, 2026 18:59
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.

1 participant