mirror of
https://github.com/containrrr/watchtower.git
synced 2026-01-24 09:46:10 +01:00
restructure and fix empty report
This commit is contained in:
parent
0776077ac5
commit
3bcc86cd8f
12 changed files with 359 additions and 343 deletions
|
|
@ -1,66 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/containrrr/watchtower/pkg/types"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
Entries []*LogEntry
|
||||
StaticData StaticData
|
||||
Report types.Report
|
||||
}
|
||||
|
||||
type StaticData struct {
|
||||
Title string
|
||||
Host string
|
||||
}
|
||||
|
||||
type LogEntry struct {
|
||||
Message string
|
||||
Data map[string]any
|
||||
Time time.Time
|
||||
Level LogLevel
|
||||
}
|
||||
|
||||
type LogLevel string
|
||||
|
||||
const (
|
||||
TraceLevel LogLevel = "trace"
|
||||
DebugLevel LogLevel = "debug"
|
||||
InfoLevel LogLevel = "info"
|
||||
WarnLevel LogLevel = "warning"
|
||||
ErrorLevel LogLevel = "error"
|
||||
FatalLevel LogLevel = "fatal"
|
||||
PanicLevel LogLevel = "panic"
|
||||
)
|
||||
|
||||
func LevelsFromString(str string) []LogLevel {
|
||||
levels := make([]LogLevel, 0, len(str))
|
||||
for _, c := range str {
|
||||
switch c {
|
||||
case 'p':
|
||||
levels = append(levels, PanicLevel)
|
||||
case 'f':
|
||||
levels = append(levels, FatalLevel)
|
||||
case 'e':
|
||||
levels = append(levels, ErrorLevel)
|
||||
case 'w':
|
||||
levels = append(levels, WarnLevel)
|
||||
case 'i':
|
||||
levels = append(levels, InfoLevel)
|
||||
case 'd':
|
||||
levels = append(levels, DebugLevel)
|
||||
case 't':
|
||||
levels = append(levels, TraceLevel)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
return levels
|
||||
}
|
||||
|
||||
func (level LogLevel) String() string {
|
||||
return string(level)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue