Skip to content

Commit

Permalink
shovel: change logging fields order
Browse files Browse the repository at this point in the history
I like it when the left side of a log line doesn't change as much as the
right.
  • Loading branch information
ryandotsmith committed May 2, 2024
1 parent d08c9fc commit 4bfc0d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions shovel/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,13 @@ func (task *Task) Converge() error {
return fmt.Errorf("committing tx: %w", err)
}
slog.InfoContext(ctx, "converge",
"src", task.srcName,
"dst", task.destConfig.Name,
"n", last.num,
"h", fmt.Sprintf("%.4x", last.hash),
"nrows", last.nrows,
"nrpc", wctx.Counter(ctx),
"nblocks", delta,
"src", task.srcName,
"dst", task.destConfig.Name,
"elapsed", time.Since(t0),
)
return nil
Expand Down
11 changes: 5 additions & 6 deletions wslog/slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ func (h *Handler) Handle(ctx context.Context, r slog.Record) error {
*bufp = buf
freebuf(bufp)
}()
if len(r.Message) > 0 {
buf = append(buf, 'm', 's', 'g', '=')
buf = append(buf, []byte(r.Message)...)
buf = append(buf, ' ')
}
buf = append(buf, h.preformat...)
for _, f := range h.ctxs {
k, v := f(ctx)
Expand All @@ -126,12 +131,6 @@ func (h *Handler) Handle(ctx context.Context, r slog.Record) error {
buf = h.appendAttr(buf, h.prefix, a)
return true
})

if len(r.Message) > 0 {
buf = append(buf, 'm', 's', 'g', '=')
buf = append(buf, []byte(r.Message)...)
}

buf = bytes.TrimSuffix(buf, []byte(" "))
buf = append(buf, '\n')
h.mu.Lock()
Expand Down

0 comments on commit 4bfc0d7

Please sign in to comment.