mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-03 20:40:00 -05:00
It was a good decision in hindsight to keep the public module as 0.x because this would have been a breaking change again. https://mattermost.atlassian.net/browse/MM-53032 ```release-note Changed the Go module path from github.com/mattermost/mattermost-server/server/v8 to github.com/mattermost/mattermost/server/v8. For the public facing module, it's path is also changed from github.com/mattermost/mattermost-server/server/public to github.com/mattermost/mattermost/server/public ```
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package human
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
)
|
|
|
|
type LogEntry struct {
|
|
Time time.Time
|
|
Level string
|
|
Message string
|
|
Caller string
|
|
Fields []mlog.Field
|
|
}
|
|
|
|
// Provide default string representation. Used by SimpleWriter
|
|
func (f LogEntry) String() string {
|
|
var sb strings.Builder
|
|
if !f.Time.IsZero() {
|
|
sb.WriteString(f.Time.Format(time.RFC3339Nano))
|
|
sb.WriteRune(' ')
|
|
}
|
|
if f.Level != "" {
|
|
sb.WriteString(f.Level)
|
|
sb.WriteRune(' ')
|
|
}
|
|
if f.Caller != "" {
|
|
sb.WriteString(f.Caller)
|
|
sb.WriteRune(' ')
|
|
}
|
|
for _, field := range f.Fields {
|
|
sb.WriteString(field.Key)
|
|
sb.WriteRune('=')
|
|
sb.WriteString(fmt.Sprint(field.Interface))
|
|
sb.WriteRune(' ')
|
|
}
|
|
if f.Message != "" {
|
|
// If the message is multiple lines, start the whole message on a new line
|
|
if strings.ContainsRune(f.Message, '\n') {
|
|
sb.WriteRune('\n')
|
|
}
|
|
sb.WriteString(f.Message)
|
|
}
|
|
|
|
return sb.String()
|
|
}
|