Skip to content

Commit

Permalink
feat: add config toggle for status request logging
Browse files Browse the repository at this point in the history
  • Loading branch information
davidramiro committed Feb 19, 2023
1 parent fd9fc11 commit caab0b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions cmd/fritzgandi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ func initEcho() {
uri = re.ReplaceAllString(v.URI, `apikey=**REDACTED**`)
}

logger.Info().
Str("URI", uri).
Int("status", v.Status).
Msg("request")
if configuration.Api.StatusLogEnabled || !strings.Contains(v.URI, "/status") {
logger.Info().
Str("URI", uri).
Int("status", v.Status).
Msg("request")
}

return nil
},
Expand Down
3 changes: 2 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ gandi:
ttl: 300
api:
port: 9595
hideApiKeyInLogs: true
hideApiKeyInLogs: true
enableStatusLog: false
5 changes: 3 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ type Config struct {
} `yaml:"gandi"`

Api struct {
Port string `yaml:"port"`
ApiKeyHidden bool `yaml:"hideApiKeyInLogs"`
Port string `yaml:"port"`
ApiKeyHidden bool `yaml:"hideApiKeyInLogs"`
StatusLogEnabled bool `yaml:"enableStatusLog"`
} `yaml:"api"`
}

Expand Down

0 comments on commit caab0b0

Please sign in to comment.