Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Add the ability to set the log level at startup
Browse files Browse the repository at this point in the history
Previously, in order to change the log level, one must exec into each
container and run a command. This is nice for existing containers, but
can be tedious if trying to run containers from the start with a log
level different from "info."

This change adds the ability to set an environment variable and start
the container with a desired log level.

Signed-off-by: Donnie Adams <donnie@acorn.io>
  • Loading branch information
thedadams committed Aug 16, 2023
1 parent 2e9f5e8 commit 60aac01
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/logserver/logserver.go
Expand Up @@ -24,9 +24,14 @@ type Server struct {
Debug bool
}

// StartServerWithDefaults starts the server with default values
// StartServerWithDefaults starts the server with default values. If the ACORN_LOG_LEVEL environment variable is set,
// it will be parsed and used to set the log level.
func StartServerWithDefaults() {
logrus.SetLevel(logrus.InfoLevel)
if level, err := logrus.ParseLevel(os.Getenv("ACORN_LOG_LEVEL")); err == nil {
logrus.SetLevel(level)
} else {
logrus.SetLevel(logrus.InfoLevel)
}
s := Server{
SocketLocation: DefaultSocketLocation,
}
Expand Down

0 comments on commit 60aac01

Please sign in to comment.