File tree Expand file tree Collapse file tree 3 files changed +17
-5
lines changed
Expand file tree Collapse file tree 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ logging:
88 # This can also be set via the LOGGING_LEVEL environment variable
99 level: info
1010
11+ # Health checks
12+ #
13+ # This can also be set via the LOGGING_HEALTHCHECKS environment variable
14+ healthchecks: false
15+
1116api:
1217 # Listen address for the API
1318 #
Original file line number Diff line number Diff line change @@ -43,16 +43,21 @@ func Start(cfg *config.Config) error {
4343 router := gin .New ()
4444 // Catch panics and return a 500
4545 router .Use (gin .Recovery ())
46+ // Standard logging
47+ logger := logging .GetLogger ()
4648 // Access logging
4749 accessLogger := logging .GetAccessLogger ()
50+ skipPaths := []string {}
51+ if cfg .Logging .Healthchecks {
52+ skipPaths = append (skipPaths , "/healthcheck" )
53+ logger .Infof ("disabling access logs for /healthcheck" )
54+ }
4855 router .Use (ginzap .GinzapWithConfig (accessLogger , & ginzap.Config {
4956 TimeFormat : time .RFC3339 ,
5057 UTC : true ,
51- SkipPaths : [] string { "/healthcheck" } ,
58+ SkipPaths : skipPaths ,
5259 }))
5360 router .Use (ginzap .RecoveryWithZap (accessLogger , true ))
54- // Standard logging
55- logger := logging .GetLogger ()
5661
5762 // Create a healthcheck (before metrics so it's not instrumented)
5863 router .GET ("/healthcheck" , handleHealthcheck )
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ type Config struct {
1818}
1919
2020type LoggingConfig struct {
21- Level string `yaml:"level" envconfig:"LOGGING_LEVEL"`
21+ Healthchecks bool `yaml:"healthchecks" envconfig:"LOGGING_HEALTHCHECKS"`
22+ Level string `yaml:"level" envconfig:"LOGGING_LEVEL"`
2223}
2324
2425type ApiConfig struct {
@@ -47,7 +48,8 @@ type NodeConfig struct {
4748// Singleton config instance with default values
4849var globalConfig = & Config {
4950 Logging : LoggingConfig {
50- Level : "info" ,
51+ Level : "info" ,
52+ Healthchecks : false ,
5153 },
5254 Api : ApiConfig {
5355 ListenAddress : "" ,
You can’t perform that action at this time.
0 commit comments