forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
37 lines (28 loc) · 830 Bytes
/
config.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
package logger
import (
"fmt"
"github.com/sirupsen/logrus"
)
type (
// LogLevel is a config field type holding minimal log level.
// It's compatible with logrus level types.
LogLevel logrus.Level
// Config is responsible for configuring logger.
Config struct {
// Level sets the minimal logging level
// values: debug, info (default), warn, warning, error, fatal, panic
Level LogLevel `envconfig:"default=info"`
// BuildHash holds hash of the git commit from which binary was build.
BuildHash string `envconfig:"-"`
}
)
// Unmarshal provides custom parsing of Log Level.
// Implements envconfig.Unmarshal interface.
func (m *LogLevel) Unmarshal(in string) error {
out, err := logrus.ParseLevel(in)
if err != nil {
return fmt.Errorf("unable to unmarshal %s", in)
}
*m = LogLevel(out)
return nil
}