feat: suppress log package logging (#3076)

To suppress uber-go/tally logs which are not structured logs.
This commit is contained in:
Ken Kaizu
2023-01-31 14:55:01 +09:00
committed by GitHub
parent 75c4c1fdcf
commit fdcb1adfb0
3 changed files with 14 additions and 0 deletions

View File

@@ -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{

12
server/logging/log.go Normal file
View File

@@ -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)
}

View File

@@ -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 {