Skip to content

Commit

Permalink
feat: suppress log package logging (runatlantis#3076)
Browse files Browse the repository at this point in the history
To suppress uber-go/tally logs which are not structured logs.
  • Loading branch information
krrrr38 authored and ijames-gc committed Feb 13, 2024
1 parent 861ffc2 commit c14cdd3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/controllers/events/events_controller_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()

// Real dependencies.
logging.SuppressDefaultLogging()
logger := logging.NewNoopLogger(t)

eventParser := &events.EventParser{
Expand Down
12 changes: 12 additions & 0 deletions server/logging/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package logging

import (
"io"
"log"
)

// SuppressDefaultLogging suppresses the default logging
func SuppressDefaultLogging() {
// Some packages use the default logger, so we need to suppress it. (such as uber-go/tally)
log.SetOutput(io.Discard)
}
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ type WebhookConfig struct {
// its dependencies an error will be returned. This is like the main() function
// for the server CLI command because it injects all the dependencies.
func NewServer(userConfig UserConfig, config Config) (*Server, error) {
logging.SuppressDefaultLogging()
logger, err := logging.NewStructuredLoggerFromLevel(userConfig.ToLogLevel())

if err != nil {
Expand Down

0 comments on commit c14cdd3

Please sign in to comment.