Skip to content

Commit

Permalink
add loglevel, remove debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Novgorodov Igor, PMK-TV-OP authored and Novgorodov Igor, PMK-TV-OP committed Aug 26, 2019
1 parent b5c29da commit 82478ea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type config struct {

StatsInterval duration `toml:"stats_interval"`
BufferSize int `toml:"buffer_size"`
LogLevel string `toml:"log_level"`

Inputs map[string]*inputCfg `toml:"input"`
Outputs map[string]*outputCfg `toml:"output"`
Expand Down
25 changes: 15 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@ func main() {
chanClose := make(chan struct{})

configFile := flag.String("config", "/etc/riemann-relay/riemann-relay.conf", "Path to a config file")
debug := flag.Bool("debug", false, "Enable debug logging (use with care - a LOT of output)")
flag.Parse()

if *debug {
log.SetLevel(log.DebugLevel)
l.Infof("Debugging enabled")
}

if err = configLoad(*configFile); err != nil {
l.Fatalf("Unable to load config file: %s", err)
}
l.Infof("Configuration loaded")

if cfg.LogLevel != "" {
lvl, err := log.ParseLevel(cfg.LogLevel)
if err != nil {
log.Fatalf("Unable to parse '%s' as log level: %s", cfg.LogLevel, err)
}

log.SetLevel(lvl)
} else {
log.SetLevel(log.WarnLevel)
}

// Fire up outputs
for _, c := range cfg.Outputs {
o, err := newOutput(c)
Expand All @@ -44,7 +49,7 @@ func main() {

outputs[c.Name] = o
}
l.Infof("Outputs started: %d", len(outputs))
l.Warnf("Outputs started: %d", len(outputs))

// Fire up inputs
unusedOutputs := map[string]bool{}
Expand All @@ -69,13 +74,13 @@ func main() {

inputs[c.Name] = i
}
l.Infof("Inputs started: %d", len(inputs))
l.Warnf("Inputs started: %d", len(inputs))

if len(unusedOutputs) > 0 {
l.Fatalf("Unused outputs in a config file: %+v", unusedOutputs)
}

l.Infof("HTTP listening to %s", cfg.ListenHTTP)
l.Warnf("HTTP listening to %s", cfg.ListenHTTP)
go initHTTP()

// Set up signal handling
Expand Down Expand Up @@ -106,5 +111,5 @@ func main() {
o.Close()
}

l.Infof("Shutdown complete")
l.Warnf("Shutdown complete")
}
3 changes: 3 additions & 0 deletions riemann-relay.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ listen_http = "127.0.0.1:9999"
## How frequently to print stats in the logs
stats_interval = "5s"

## Logging level
log_level = "debug"

# One or more inputs under 'input' subtree
[input.input1]
# Listen parameters can be IP:Port or Unix Socket path
Expand Down
27 changes: 0 additions & 27 deletions riemann.proto3

This file was deleted.

0 comments on commit 82478ea

Please sign in to comment.