Skip to content

Commit

Permalink
Initialize log config earlier to prevent trace messages being printed…
Browse files Browse the repository at this point in the history
… early on (#1939)

like TRC DNS configuration loaded dns_config={....}
  • Loading branch information
SuperSandro2000 authored May 16, 2024
1 parent 7fd2485 commit a9763c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cmd/headscale/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func initConfig() {

machineOutput := HasMachineOutputFlag()

zerolog.SetGlobalLevel(cfg.Log.Level)

// If the user has requested a "node" readable format,
// then disable login so the output remains valid.
if machineOutput {
Expand Down
9 changes: 6 additions & 3 deletions hscontrol/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,9 @@ func GetHeadscaleConfig() (*Config, error) {
}, nil
}

logConfig := GetLogConfig()
zerolog.SetGlobalLevel(logConfig.Level)

prefix4, err := PrefixV4()
if err != nil {
return nil, err
Expand Down Expand Up @@ -667,7 +670,7 @@ func GetHeadscaleConfig() (*Config, error) {

dnsConfig, baseDomain := GetDNSConfig()
derpConfig := GetDERPConfig()
logConfig := GetLogTailConfig()
logTailConfig := GetLogTailConfig()
randomizeClientPort := viper.GetBool("randomize_client_port")

oidcClientSecret := viper.GetString("oidc.client_secret")
Expand Down Expand Up @@ -749,7 +752,7 @@ func GetHeadscaleConfig() (*Config, error) {
UseExpiryFromToken: viper.GetBool("oidc.use_expiry_from_token"),
},

LogTail: logConfig,
LogTail: logTailConfig,
RandomizeClientPort: randomizeClientPort,

ACL: GetACLConfig(),
Expand All @@ -761,7 +764,7 @@ func GetHeadscaleConfig() (*Config, error) {
Insecure: viper.GetBool("cli.insecure"),
},

Log: GetLogConfig(),
Log: logConfig,

// TODO(kradalby): Document these settings when more stable
Tuning: Tuning{
Expand Down

0 comments on commit a9763c9

Please sign in to comment.