Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Update deps to pull in additional logging changes.
Browse files Browse the repository at this point in the history
This update adds additional callsite logging options via btclog and
fixes an error with the rotator package that caused it to stop running
when creating any log messages larger than 4096 bytes.

While here, switch to the new Write method of the Rotator object as
this is more efficient than using the Reader interface with a pipe.
  • Loading branch information
jrick committed Jun 28, 2017
1 parent 2ffbad1 commit 7131649
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
10 changes: 5 additions & 5 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package main

import (
"fmt"
"io"
"os"
"path/filepath"

Expand Down Expand Up @@ -36,7 +35,7 @@ type logWriter struct{}

func (logWriter) Write(p []byte) (n int, err error) {
os.Stdout.Write(p)
logRotatorPipe.Write(p)
logRotator.Write(p)
return len(p), nil
}

Expand All @@ -58,10 +57,6 @@ var (
// application shutdown.
logRotator *rotator.Rotator

// logRotatorPipe is the write-end pipe for writing to the log rotator. It
// is written to by the Write method of the logWriter type.
logRotatorPipe *io.PipeWriter

adxrLog = backendLog.Logger("ADXR")
amgrLog = backendLog.Logger("AMGR")
cmgrLog = backendLog.Logger("CMGR")
Expand Down Expand Up @@ -123,17 +118,13 @@ func initLogRotator(logFile string) {
fmt.Fprintf(os.Stderr, "failed to create log directory: %v\n", err)
os.Exit(1)
}
pr, pw := io.Pipe()
r, err := rotator.New(pr, logFile, 10*1024, false, 3)
r, err := rotator.New(logFile, 10*1024, false, 3)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to create file rotator: %v\n", err)
os.Exit(1)
}

go r.Run()

logRotator = r
logRotatorPipe = pw
}

// setLogLevel sets the logging level for provided subsystem. Invalid
Expand Down

0 comments on commit 7131649

Please sign in to comment.