mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add missing parts from previous commit
This commit is contained in:
parent
14bc27f178
commit
5beed9f75d
3 changed files with 3 additions and 5 deletions
|
|
@ -73,7 +73,7 @@ type TerminalStringer interface {
|
||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
// [DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002
|
// [DBUG] [May 16 20:58:45] remove route ns=haproxy addr=127.0.0.1:50002
|
||||||
func TerminalFormat(r slog.Record, usecolor bool) []byte {
|
func TerminalFormat(r slog.Record, commonAttrs []slog.Attr, usecolor bool) []byte {
|
||||||
msg := escapeMessage(r.Message)
|
msg := escapeMessage(r.Message)
|
||||||
var color = 0
|
var color = 0
|
||||||
if usecolor {
|
if usecolor {
|
||||||
|
|
@ -106,7 +106,7 @@ func TerminalFormat(r slog.Record, usecolor bool) []byte {
|
||||||
b.Write(bytes.Repeat([]byte{' '}, termMsgJust-length))
|
b.Write(bytes.Repeat([]byte{' '}, termMsgJust-length))
|
||||||
}
|
}
|
||||||
// print the keys logfmt style
|
// print the keys logfmt style
|
||||||
logfmt(b, []slog.Attr{}, r, color, true)
|
logfmt(b, commonAttrs, r, color, true)
|
||||||
return b.Bytes()
|
return b.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,8 +140,7 @@ func TerminalHandlerWithLevel(wr io.Writer, lvl slog.Level, useColor bool) slog.
|
||||||
func (h *terminalHandler) Handle(_ context.Context, r slog.Record) error {
|
func (h *terminalHandler) Handle(_ context.Context, r slog.Record) error {
|
||||||
h.mu.Lock()
|
h.mu.Lock()
|
||||||
defer h.mu.Unlock()
|
defer h.mu.Unlock()
|
||||||
r.AddAttrs(h.attrs...)
|
h.wr.Write(TerminalFormat(r, h.attrs, h.useColor))
|
||||||
h.wr.Write(TerminalFormat(r, h.useColor))
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"golang.org/x/exp/slog"
|
"golang.org/x/exp/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue