fix: clean log formatter - remove message field redundancy
This commit is contained in:
@@ -227,26 +227,29 @@ func (f *CleanFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
|||||||
// Column 3: Message
|
// Column 3: Message
|
||||||
output.WriteString(entry.Message)
|
output.WriteString(entry.Message)
|
||||||
|
|
||||||
// Append important fields in a clean format (skip internal fields)
|
// Append important fields in a clean format (skip internal/redundant fields)
|
||||||
if len(entry.Data) > 0 {
|
if len(entry.Data) > 0 {
|
||||||
|
// Only show truly important fields, skip verbose ones
|
||||||
for k, v := range entry.Data {
|
for k, v := range entry.Data {
|
||||||
// Skip noisy internal fields
|
// Skip noisy internal fields and redundant message field
|
||||||
if k == "elapsed" || k == "operation_id" || k == "step" || k == "timestamp" {
|
if k == "elapsed" || k == "operation_id" || k == "step" || k == "timestamp" || k == "message" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format duration nicely
|
// Format duration nicely at the end
|
||||||
if k == "duration" {
|
if k == "duration" {
|
||||||
if str, ok := v.(string); ok {
|
if str, ok := v.(string); ok {
|
||||||
output.WriteString(fmt.Sprintf(" [duration: %s]", str))
|
output.WriteString(fmt.Sprintf(" (%s)", str))
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add other fields
|
// Only show critical fields (driver, errors, etc)
|
||||||
|
if k == "driver" || k == "max_conns" || k == "error" || k == "database" {
|
||||||
output.WriteString(fmt.Sprintf(" %s=%v", k, v))
|
output.WriteString(fmt.Sprintf(" %s=%v", k, v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output.WriteString("\n")
|
output.WriteString("\n")
|
||||||
return []byte(output.String()), nil
|
return []byte(output.String()), nil
|
||||||
|
|||||||
Reference in New Issue
Block a user