Skip to content

Commit

Permalink
Add a combined write syncer to the disk logging for zap
Browse files Browse the repository at this point in the history
  • Loading branch information
stevededalus committed Apr 27, 2017
1 parent 7167c75 commit 09720c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions benchmarks/runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func spawnGateway(dirName string) *exec.Cmd {
"metrics.m3.hostPort": "127.0.0.1:8053",
"metrics.tally.service": "bench-gateway",
"logger.fileName": path.Join(logTempDir, "zanzibar.log"),
"logger.output": "disk",
"clients.contacts.port": 8092,
"clients.googleNow.port": 8092,
"clients.baz.port": 8094,
Expand Down
7 changes: 6 additions & 1 deletion runtime/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,12 @@ func (gateway *Gateway) setupLogger(config *StaticConfig) error {
return errors.Wrap(err, "Error opening log file")
}
gateway.loggerFile = loggerFile
output = loggerFile
if gateway.logWriter != nil {
writer := zap.CombineWriteSyncers(loggerFile, gateway.logWriter)
output = writer
} else {
output = loggerFile
}
}

zapLogger := zap.New(
Expand Down
3 changes: 2 additions & 1 deletion test/lib/bench_gateway/bench_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func CreateGateway(
}
seedConfig["tchannel.processName"] = "bench-gateway"
seedConfig["metrics.tally.service"] = "bench-gateway"
seedConfig["logger.output"] = "stdout"
seedConfig["logger.output"] = "disk"
seedConfig["logger.fileName"] = "zanzibar.log"

benchGateway := &BenchGateway{
httpClient: &http.Client{
Expand Down

0 comments on commit 09720c3

Please sign in to comment.