-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (32 loc) · 1.1 KB
/
main.go
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
36
37
38
39
package main
import (
"flag"
"os"
"strings"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog/pkgerrors"
"github.com/MashinaMashina/api-tests/service"
)
func main() {
noColor := flag.Bool("nocolor", false, "disable output coloring")
loglevel := flag.String("level", "trace", "log level (panic, fatal, error, warn, info, debug, trace)")
dir := flag.String("dir", "tests", "tests directory")
pattern := flag.String("pattern", "", "pattern for tests")
flag.Parse()
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack
zerolog.TimestampFieldName = "_t"
zerolog.LevelFieldName = "_l"
zerolog.MessageFieldName = "_m"
zerolog.ErrorFieldName = "_e"
w := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: "15:04:05", NoColor: *noColor}
log.Logger = zerolog.New(w).With().Timestamp().Logger()
level, err := zerolog.ParseLevel(strings.ToLower(*loglevel))
if err != nil {
log.Error().Stack().Err(err).Msg("failed to parse logging level")
level = zerolog.InfoLevel
}
zerolog.SetGlobalLevel(level)
service.Run(*dir, *pattern)
}