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
|
package common
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
InitLogging(ioutil.Discard, os.Stdout, os.Stdout, os.Stderr)
|
InitDefaultLogging(false)
|
||||||
}
|
}
|
||||||
+15
-23
@@ -3,8 +3,6 @@ package common
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -40,33 +38,27 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Log *logrus.Logger
|
Log *logrus.Logger
|
||||||
Info *logrus.Logger
|
Info *logrus.Logger
|
||||||
debugF bool
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitLogging(debugHandle io.Writer,
|
func InitLogging(level logrus.Level) {
|
||||||
infoHandle io.Writer,
|
if Info == nil {
|
||||||
warningHandle io.Writer,
|
Info = &logrus.Logger{
|
||||||
errorHandle io.Writer) {
|
Out: os.Stderr,
|
||||||
|
Formatter: standardTextFormatter,
|
||||||
Info = &logrus.Logger{
|
Hooks: make(logrus.LevelHooks),
|
||||||
Out: infoHandle,
|
Level: level,
|
||||||
Formatter: standardTextFormatter,
|
}
|
||||||
Hooks: make(logrus.LevelHooks),
|
Log = Info
|
||||||
Level: logrus.InfoLevel,
|
|
||||||
}
|
}
|
||||||
Log = Info
|
Info.Level = level
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitDefaultLogging(debug bool) {
|
func InitDefaultLogging(debug bool) {
|
||||||
if debug == debugF {
|
level := logrus.InfoLevel
|
||||||
return
|
|
||||||
}
|
|
||||||
debugF = debug
|
|
||||||
debugOut := ioutil.Discard
|
|
||||||
if debug {
|
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