Skip to content

Commit

Permalink
feat(echo): set log level according to env
Browse files Browse the repository at this point in the history
Set the log level according to the value of YGG_LOG_LEVEL.
Print the worker's environment when run at level Debug or higher.

Signed-off-by: Link Dupont <link@sub-pop.net>
  • Loading branch information
subpop authored and jirihnidek committed Apr 16, 2024
1 parent c1e4a4d commit 3a2b3d1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions worker/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ import (
var yggdDispatchSocketAddr string

func main() {
// Set log level inherited from the environment
if logLevel, ok := os.LookupEnv("YGG_LOG_LEVEL"); ok {
level, err := log.ParseLevel(logLevel)
if err != nil {
log.Fatalf("cannot parse log level: %v", err)
}
log.SetLevel(level)
}
log.Debugf("current environment: %v", os.Environ())

// Get initialization values from the environment.
var ok bool
yggdDispatchSocketAddr, ok = os.LookupEnv("YGG_SOCKET_ADDR")
Expand Down

0 comments on commit 3a2b3d1

Please sign in to comment.