...
1 package gonja_test
2
3 import (
4 "flag"
5 "os"
6 "testing"
7
8 . "github.com/go-check/check"
9 log "github.com/sirupsen/logrus"
10 prefixed "github.com/x-cray/logrus-prefixed-formatter"
11 )
12
13
14 func Test(t *testing.T) { TestingT(t) }
15
16 var (
17 logLevel = flag.String("log.level", "", "Log Level")
18 )
19
20 func TestMain(m *testing.M) {
21 flag.Parse()
22
23 log.SetFormatter(&prefixed.TextFormatter{
24 ForceColors: true,
25 DisableTimestamp: true,
26 ForceFormatting: true,
27 })
28
29 switch *logLevel {
30 case "error":
31 log.SetLevel(log.ErrorLevel)
32 case "warning", "warn":
33 log.SetLevel(log.WarnLevel)
34 case "info":
35 log.SetLevel(log.InfoLevel)
36 case "debug":
37 log.SetLevel(log.DebugLevel)
38 case "trace":
39 log.SetLevel(log.TraceLevel)
40 default:
41 log.SetLevel(log.PanicLevel)
42 }
43 code := m.Run()
44 os.Exit(code)
45 }
46
View as plain text