Skip to content

Commit a8f9bec

Browse files
krrrr38ijames-gc
authored andcommitted
feat: suppress log package logging (runatlantis#3076)
To suppress uber-go/tally logs which are not structured logs.
1 parent 3ec2799 commit a8f9bec

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

server/controllers/events/events_controller_e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,7 @@ func setupE2E(t *testing.T, repoDir string, opt setupOption) (events_controllers
10631063
projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler()
10641064

10651065
// Real dependencies.
1066+
logging.SuppressDefaultLogging()
10661067
logger := logging.NewNoopLogger(t)
10671068

10681069
eventParser := &events.EventParser{

server/logging/log.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package logging
2+
3+
import (
4+
"io"
5+
"log"
6+
)
7+
8+
// SuppressDefaultLogging suppresses the default logging
9+
func SuppressDefaultLogging() {
10+
// Some packages use the default logger, so we need to suppress it. (such as uber-go/tally)
11+
log.SetOutput(io.Discard)
12+
}

server/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ type WebhookConfig struct {
153153
// its dependencies an error will be returned. This is like the main() function
154154
// for the server CLI command because it injects all the dependencies.
155155
func NewServer(userConfig UserConfig, config Config) (*Server, error) {
156+
logging.SuppressDefaultLogging()
156157
logger, err := logging.NewStructuredLoggerFromLevel(userConfig.ToLogLevel())
157158

158159
if err != nil {

0 commit comments

Comments
 (0)