Update deps to pull in additional logging changes.

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.

Changes from @jrick.
This commit is contained in:
Dave Collins 2017-08-24 17:25:37 -05:00
parent 34b1373a68
commit 9b0884286f
No known key found for this signature in database
GPG key ID: B8904D9D9C93D1F2
2 changed files with 5 additions and 14 deletions

6
glide.lock generated
View file

@ -1,8 +1,8 @@
hash: 976decfaf173d97d2e4572399490637aa12e217312a7d8b28813780a738e1151
updated: 2017-08-15T20:07:19.2012575-05:00
updated: 2017-08-24T17:28:45.8117156-05:00
imports:
- name: github.com/btcsuite/btclog
version: 96c2a91a67da03552a5e6554fe3ccbfbc7f860be
version: 84c8d2346e9fc8c7b947e243b9c24e6df9fd206a
- name: github.com/btcsuite/btcutil
version: 501929d3d046174c3d39f0ea54ece471aa17238c
subpackages:
@ -47,7 +47,7 @@ imports:
- name: github.com/jessevdk/go-flags
version: 1679536dcc895411a9f5848d9a0250be7856448c
- name: github.com/jrick/logrotate
version: 4ed05ed86ef17d10ff99cce77481e0fcf6f2c7b0
version: a93b200c26cbae3bb09dd0dc2c7c7fe1468a034a
subpackages:
- rotator
- name: golang.org/x/crypto

13
log.go
View file

@ -7,7 +7,6 @@ package main
import (
"fmt"
"io"
"os"
"path/filepath"
@ -31,7 +30,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
}
@ -53,10 +52,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")
@ -117,17 +112,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