Skip to content

Commit bcdfa49

Browse files
config: make log level configurable
1 parent 11462cf commit bcdfa49

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ type Config struct {
1717
Matrix signaling.Config `yaml:"matrix"`
1818
// Conference (call) configuration.
1919
Conference conference.Config `yaml:"conference"`
20+
// Starting from which level to log stuff.
21+
LogLevel string `yaml:"log"`
2022
}
2123

2224
// Tries to load a config from the `CONFIG` environment variable.

pkg/main.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ func main() {
4040
// Initialize logging subsystem (formatting, global logging framework etc).
4141
logrus.SetFormatter(&logrus.TextFormatter{FullTimestamp: true, ForceColors: true})
4242

43-
// Temporarily enable debug logging.
44-
logrus.SetLevel(logrus.DebugLevel)
45-
4643
// Define functions that are called before exiting.
4744
// This is useful to stop the profiler if it's enabled.
4845
deferred_functions := []func(){}
@@ -71,6 +68,23 @@ func main() {
7168
return
7269
}
7370

71+
switch config.LogLevel {
72+
case "debug":
73+
logrus.SetLevel(logrus.DebugLevel)
74+
case "info":
75+
logrus.SetLevel(logrus.InfoLevel)
76+
case "warn":
77+
logrus.SetLevel(logrus.WarnLevel)
78+
case "error":
79+
logrus.SetLevel(logrus.ErrorLevel)
80+
case "fatal":
81+
logrus.SetLevel(logrus.FatalLevel)
82+
case "panic":
83+
logrus.SetLevel(logrus.PanicLevel)
84+
default:
85+
logrus.SetLevel(logrus.InfoLevel)
86+
}
87+
7488
// Create matrix client.
7589
matrixClient := signaling.NewMatrixClient(config.Matrix)
7690

0 commit comments

Comments
 (0)