build/log: add log types + NewSubLogger

This commit is contained in:
Conner Fromknecht committed 2018-10-05 13:04:45 +09:00
1 parent 4ea1a40a88
commit 9654a1c619
4 files changed
+138

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
// +build !stdlog,!nolog
package build
import "os"
// LoggingType is a log type that writes to both stdout and the log rotator, if
// present.
const LoggingType = LogTypeDefault
// Write writes the byte slice to both stdout and the log rotator, if present.
func (w *LogWriter) Write(b []byte) (int, error) {
os.Stdout.Write(b)
if w.RotatorPipe != nil {
w.RotatorPipe.Write(b)
}
return len(b), nil
}