-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.go
More file actions
30 lines (26 loc) · 743 Bytes
/
base.go
File metadata and controls
30 lines (26 loc) · 743 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
package config
import (
joonix "github.com/numbergroup/log"
"github.com/sirupsen/logrus"
)
type BaseConfig struct {
Name string `env:"NAME" env-default:""`
Version string `env:"VERSION" env-default:""`
Verbosity string `env:"VERBOSITY" env-default:"INFO"`
FluentDLogging bool `env:"FLUENT_D_LOGGING" env-default:"false"`
Production bool `env:"PRODUCTION" env-default:"false"`
}
func (c BaseConfig) GetLogger() *logrus.Logger {
logger := logrus.New()
lvl, err := logrus.ParseLevel(c.Verbosity)
if err != nil {
logger.SetLevel(logrus.InfoLevel)
} else {
logger.SetLevel(lvl)
}
logger.SetReportCaller(true)
if c.FluentDLogging {
logger.SetFormatter(joonix.NewFormatter())
}
return logger
}