Skip to content

Commit 71d729e

Browse files
committed
Rename Loggers -> Names
1 parent f9e58d4 commit 71d729e

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

internal/entryhuman/entry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ func Fmt(w io.Writer, ent slog.SinkEntry) string {
5858
level = c(w, levelColor(ent.Level)).Sprint(level)
5959
ents += fmt.Sprintf("%v\t", level)
6060

61-
if len(ent.Loggers) > 0 {
62-
component := "(" + quoteKey(strings.Join(ent.Loggers, ".")) + ")"
61+
if len(ent.Names) > 0 {
62+
component := "(" + quoteKey(strings.Join(ent.Names, ".")) + ")"
6363
component = c(w, color.FgMagenta).Sprint(component)
6464
ents += fmt.Sprintf("%v\t", component)
6565
}

internal/entryhuman/entry_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ line2`)
5151
t.Parallel()
5252

5353
test(t, slog.SinkEntry{
54-
Level: slog.LevelWarn,
55-
Loggers: []string{"named", "meow"},
54+
Level: slog.LevelWarn,
55+
Names: []string{"named", "meow"},
5656
}, `0001-01-01 00:00:00.000 [WARN] (named.meow) <.:0> ""`)
5757
})
5858

slog.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ type SinkEntry struct {
7777
Level Level
7878
Message string
7979

80-
Loggers []string
80+
// Names represents the chain of names on the
81+
// logger constructed with Named.
82+
Names []string
8183

8284
Func string
8385
File string
@@ -340,9 +342,9 @@ func (ent SinkEntry) fillLoc(skip int) SinkEntry {
340342
func (s sink) entry(ctx context.Context, ent SinkEntry) SinkEntry {
341343
s = s.withContext(ctx)
342344
s = s.withFields(ent.Fields)
343-
s = s.named(ent.Loggers...)
345+
s = s.named(ent.Names...)
344346

345-
ent.Loggers = s.name
347+
ent.Names = s.name
346348
ent.Fields = s.fields
347349

348350
return ent

slog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestLogger(t *testing.T) {
108108
Level: slog.LevelInfo,
109109
Message: "meow",
110110

111-
Loggers: []string{"hello", "hello2"},
111+
Names: []string{"hello", "hello2"},
112112

113113
File: slogTestFile,
114114
Func: "cdr.dev/slog_test.TestLogger.func3",

sloggers/slogjson/slogjson.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func (s jsonSink) LogEntry(ctx context.Context, ent slog.SinkEntry) error {
5454
slog.F("func", ent.Func),
5555
)
5656

57-
if len(ent.Loggers) > 0 {
58-
m = append(m, slog.F("component", ent.Loggers))
57+
if len(ent.Names) > 0 {
58+
m = append(m, slog.F("component", ent.Names))
5959
}
6060

6161
if ent.SpanContext != (trace.SpanContext{}) {

sloggers/slogstackdriver/slogstackdriver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ func (s stackdriverSink) LogEntry(ctx context.Context, ent slog.SinkEntry) error
5959
}),
6060
)
6161

62-
if len(ent.Loggers) > 0 {
62+
if len(ent.Names) > 0 {
6363
e = append(e, slog.F("logging.googleapis.com/operation", &logpb.LogEntryOperation{
64-
Producer: strings.Join(ent.Loggers, "."),
64+
Producer: strings.Join(ent.Names, "."),
6565
}))
6666
}
6767

0 commit comments

Comments
 (0)