You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
945 B
45 lines
945 B
package flog |
|
|
|
import ( |
|
"io" |
|
"time" |
|
) |
|
|
|
// LevelType defines the level type |
|
type LevelType uint8 |
|
|
|
// All possible log levels |
|
const ( |
|
LevelDebug LevelType = iota |
|
LevelInfo |
|
LevelWarning |
|
LevelError |
|
LevelCritical |
|
) |
|
|
|
var levels = []string{`debug`, `info`, `warning`, `error`, `critical`} |
|
|
|
// String returns the name of the level as string |
|
func (l LevelType) String() string { |
|
return levels[l] |
|
} |
|
|
|
// LogEntry is an entry for the log |
|
type LogEntry struct { |
|
Level LevelType `json:"level"` |
|
Time time.Time `json:"time"` |
|
Message string `json:"message"` |
|
StackTrace []StackTraceEntry `json:"stack_trace,omitempty"` |
|
} |
|
|
|
// StackTraceEntry is an entry in the stack trace |
|
type StackTraceEntry struct { |
|
Function string `json:"function"` |
|
File string `json:"file"` |
|
Line int `json:"line"` |
|
} |
|
|
|
// LogFormatType defines the log format |
|
type LogFormatType interface { |
|
FormatMessage(io.Writer, LogEntry) |
|
}
|
|
|