Wire up selection of logging levels to match old behaviour
- note that all output is now going to stderr.
This commit is contained in:
1 parent
67a6961b4b
commit
7276fc1d4b
2 files changed
+16
-29
No files matched your search
+1
-6
@@ -1,10 +1,5 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
func init() {
|
||||
InitLogging(ioutil.Discard, os.Stdout, os.Stdout, os.Stderr)
|
||||
InitDefaultLogging(false)
|
||||
}
|
||||
+15
-23
@@ -3,8 +3,6 @@ package common
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -40,33 +38,27 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
Log *logrus.Logger
|
||||
Info *logrus.Logger
|
||||
debugF bool
|
||||
Log *logrus.Logger
|
||||
Info *logrus.Logger
|
||||
)
|
||||
|
||||
func InitLogging(debugHandle io.Writer,
|
||||
infoHandle io.Writer,
|
||||
warningHandle io.Writer,
|
||||
errorHandle io.Writer) {
|
||||
|
||||
Info = &logrus.Logger{
|
||||
Out: infoHandle,
|
||||
Formatter: standardTextFormatter,
|
||||
Hooks: make(logrus.LevelHooks),
|
||||
Level: logrus.InfoLevel,
|
||||
func InitLogging(level logrus.Level) {
|
||||
if Info == nil {
|
||||
Info = &logrus.Logger{
|
||||
Out: os.Stderr,
|
||||
Formatter: standardTextFormatter,
|
||||
Hooks: make(logrus.LevelHooks),
|
||||
Level: level,
|
||||
}
|
||||
Log = Info
|
||||
}
|
||||
Log = Info
|
||||
Info.Level = level
|
||||
}
|
||||
|
||||
func InitDefaultLogging(debug bool) {
|
||||
if debug == debugF {
|
||||
return
|
||||
}
|
||||
debugF = debug
|
||||
debugOut := ioutil.Discard
|
||||
level := logrus.InfoLevel
|
||||
if debug {
|
||||
debugOut = os.Stderr
|
||||
level = logrus.DebugLevel
|
||||
}
|
||||
InitLogging(debugOut, os.Stdout, os.Stdout, os.Stderr)
|
||||
InitLogging(level)
|
||||
}
|
||||
Reference in new issue
Block a user