summaryrefslogtreecommitdiff
path: root/log.go
blob: 47b27c46e2338ff08c0892c56efe963680d33a02 (plain)
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
40
41
42
package main

import (
	log "github.com/sirupsen/logrus"
	"github.com/spf13/viper"
	"go/types"
)

type logger types.Nil

func (logger) Write(p []byte) (n int, err error) {
	log.Info(string(p))
	return len(p), err
}

func setFormatter() {
	log.SetFormatter(&log.TextFormatter{
		ForceColors:               false,
		DisableColors:             false,
		ForceQuote:                false,
		DisableQuote:              false,
		EnvironmentOverrideColors: false,
		DisableTimestamp:          false,
		FullTimestamp:             true,
		TimestampFormat:           "",
		DisableSorting:            true,
		SortingFunc:               nil,
		DisableLevelTruncation:    false,
		PadLevelText:              false,
		QuoteEmptyFields:          false,
		FieldMap:                  nil,
		CallerPrettyfier:          nil,
	})
}

func setLevel() {
	level, err := log.ParseLevel(viper.GetStringMap("system")["loglevel"].(string))
	if err != nil {
		log.Fatalf("Error parsing log level, %s", err)
	}
	log.SetLevel(level)
}