-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (27 loc) · 749 Bytes
/
main.go
File metadata and controls
35 lines (27 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"bufio"
"fmt"
"os"
"time"
"github.com/rs/zerolog"
flag "github.com/spf13/pflag"
)
func init() {
flag.StringVarP(&zerolog.TimestampFieldName, "timestamp", "t", "time", "Timestamp field name")
flag.StringVarP(&zerolog.MessageFieldName, "message", "m", "message", "Message field name")
flag.StringVarP(&zerolog.LevelFieldName, "level", "l", "level", "Level field name")
}
func TimeOnlyOption(w *zerolog.ConsoleWriter) { w.TimeFormat = time.TimeOnly }
func main() {
scanner := bufio.NewScanner(os.Stdin)
flag.Parse()
writer := zerolog.NewConsoleWriter(TimeOnlyOption)
for scanner.Scan() {
content := scanner.Text()
_, err := writer.Write([]byte(content))
if err != nil {
fmt.Println(content)
}
}
}