logger: Disassociate shared log config between console, file and syslog (#3333)

logurs is not helping us to set different log formats (json/text) to
different loggers. Now, we create different logurs instances and call
them in errorIf and fatalIf
This commit is contained in:
Anis Elleuch
2016-11-23 20:35:04 +01:00
committed by Harshavardhana
parent 01ae5bb39c
commit 22c98d3fa2
5 changed files with 47 additions and 19 deletions

View File

@@ -39,8 +39,12 @@ func TestCallerLocation(t *testing.T) {
func TestLogger(t *testing.T) {
var buffer bytes.Buffer
var fields logrus.Fields
log.Out = &buffer
log.Formatter = new(logrus.JSONFormatter)
testLog := logrus.New()
testLog.Out = &buffer
testLog.Formatter = new(logrus.JSONFormatter)
log.mu.Lock()
log.loggers = append(log.loggers, testLog)
log.mu.Unlock()
errorIf(errors.New("Fake error"), "Failed with error.")
err := json.Unmarshal(buffer.Bytes(), &fields)