refactored elektronLogging to logging
This commit is contained in:
parent
bd8ddd1835
commit
3d201bf437
22 changed files with 32 additions and 32 deletions
62
logging/loggerConfig.go
Normal file
62
logging/loggerConfig.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
package logging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type LoggerConfig struct {
|
||||
SchedTraceConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
FilenameExtension string `yaml:"filenameExtension"`
|
||||
AllowOnConsole bool `yaml:"allowOnConsole"`
|
||||
} `yaml:"schedTrace"`
|
||||
|
||||
PCPConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
FilenameExtension string `yaml:"filenameExtension"`
|
||||
AllowOnConsole bool `yaml:"allowOnConsole"`
|
||||
} `yaml:"pcp"`
|
||||
|
||||
ConsoleConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
FilenameExtension string `yaml:"filenameExtension"`
|
||||
MinLogLevel string `yaml:"minLogLevel"`
|
||||
AllowOnConsole bool `yaml:"allowOnConsole"`
|
||||
} `yaml:"console"`
|
||||
|
||||
SPSConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
FilenameExtension string `yaml:"filenameExtension"`
|
||||
AllowOnConsole bool `yaml:"allowOnConsole"`
|
||||
} `yaml:"sps"`
|
||||
|
||||
TaskDistrConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
FilenameExtension string `yaml:"filenameExtension"`
|
||||
AllowOnConsole bool `yaml:"allowOnConsole"`
|
||||
} `yaml:"clsfnTaskDistrOverhead"`
|
||||
|
||||
SchedWindowConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
FilenameExtension string `yaml:"filenameExtension"`
|
||||
AllowOnConsole bool `yaml:"allowOnConsole"`
|
||||
} `yaml:"schedWindow"`
|
||||
|
||||
Format []string `yaml:"format"`
|
||||
}
|
||||
|
||||
func (c *LoggerConfig) GetConfig(logConfigFilename string) *LoggerConfig {
|
||||
|
||||
yamlFile, err := ioutil.ReadFile(logConfigFilename)
|
||||
if err != nil {
|
||||
log.Printf("Error in reading yaml file #%v ", err)
|
||||
}
|
||||
err = yaml.Unmarshal(yamlFile, c)
|
||||
if err != nil {
|
||||
log.Fatalf("Error in unmarshalling yaml: %v", err)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
Reference in a new issue