Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run comet standalone #3

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions mod/log/pkg/phuslu/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,27 @@ func (f *Formatter) Format(
buffer.Reset()
defer byteBufferPool.Put(buffer)

var color, label string
var label string
switch args.Level {
case "trace":
color, label = traceColor.Raw(), traceLabel
_, label = traceColor.Raw(), traceLabel
case "debug":
color, label = debugColor.Raw(), debugLabel
_, label = debugColor.Raw(), debugLabel
case "info":
color, label = infoColor.Raw(), infoLabel
_, label = infoColor.Raw(), infoLabel
case "warn":
color, label = warnColor.Raw(), warnLabel
_, label = warnColor.Raw(), warnLabel
case "error":
color, label = errorColor.Raw(), errorLabel
_, label = errorColor.Raw(), errorLabel
case "fatal":
color, label = fatalColor.Raw(), fatalLabel
_, label = fatalColor.Raw(), fatalLabel
case "panic":
color, label = panicColor.Raw(), panicLabel
_, label = panicColor.Raw(), panicLabel
default:
color, label = defaultColor.Raw(), defaultLabel
_, label = defaultColor.Raw(), defaultLabel
}

f.printWithColor(args, buffer, color, label)
f.printWithColor(args, buffer, defaultColor.Raw(), label)
f.ensureLineBreak(buffer)

if args.Stack != "" {
Expand Down Expand Up @@ -105,27 +105,22 @@ func (f *Formatter) printWithColor(
b *byteBuffer,
color, label string,
) {
var (
ok bool
kvColor Color
kColor Color
)
f.formatHeader(args, b, color, label)

b.Bytes = append(b.Bytes, ' ')
b.Bytes = append(b.Bytes, args.Message...)
for _, kv := range args.KeyValues {
b.Bytes = append(b.Bytes, ' ')
// apply the key+value color if configured, otherwise apply key color
if kvColor, ok = f.keyValColors[kv.Key+kv.Value]; ok {
/* if kvColor, ok = f.keyValColors[kv.Key+kv.Value]; ok {
b.Bytes = append(b.Bytes, kvColor.Raw()...)
} else if kColor, ok = f.keyColors[kv.Key]; ok {
b.Bytes = append(b.Bytes, kColor.Raw()...)
}
}*/
b.Bytes = append(b.Bytes, kv.Key...)
b.Bytes = append(b.Bytes, '=')
b.Bytes = append(b.Bytes, kv.Value...)
b.Bytes = append(b.Bytes, reset...)
// b.Bytes = append(b.Bytes, reset...)
}
}

Expand All @@ -135,18 +130,18 @@ func (f *Formatter) formatHeader(
b *byteBuffer,
color, label string,
) {
b.Bytes = append(b.Bytes, gray...)
// b.Bytes = append(b.Bytes, gray...)
b.Bytes = append(b.Bytes, args.Time...)
b.Bytes = append(b.Bytes, ' ')
b.Bytes = append(b.Bytes, color...)
// b.Bytes = append(b.Bytes, color...)
b.Bytes = append(b.Bytes, label...)
if args.Caller != "" {
b.Bytes = append(b.Bytes, args.Goid...)
b.Bytes = append(b.Bytes, ' ')
b.Bytes = append(b.Bytes, args.Caller...)
b.Bytes = append(b.Bytes, ' ')
}
b.Bytes = append(b.Bytes, reset...)
// b.Bytes = append(b.Bytes, reset...)
}

// ensureLineBreak ensures the log message ends with a line break.
Expand Down
2 changes: 1 addition & 1 deletion mod/log/pkg/phuslu/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (l *Logger[Impl]) msgWithContext(
// Temporary workaround to allow dynamic configuration post-logger creation.
// This is necessary due to dependencies on runtime-populated configurations.
func (l *Logger[ImplT]) WithConfig(cfg Config) *Logger[ImplT] {
l.withTimeFormat(cfg.TimeFormat)
l.withTimeFormat("RFC3339Nano")
l.withStyle(cfg.Style)
l.withLogLevel(cfg.LogLevel)
return l
Expand Down