mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-07 06:36:42 +00:00
fix: app logger formatting (#265)
From this: ``` ERR [app] reissue: failed. valid result: %v proposer: %s validator identity: %s module=server ``` to this: ``` ERR [app] reissue: failed. valid result: true proposer: 9d3b2072f96f9481de983700605fbcd9158d5b63 validator identity: 31615187759d4bdb1c43ea7e7b9be91066042fbf module=server ``` Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
25649be550
commit
094f547e7a
@ -1,6 +1,7 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -36,28 +37,35 @@ func (logger *AppLogger) SetTestingLogger(testingLogger *testing.T) *AppLogger {
|
|||||||
return logger
|
return logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func format(msg string, keyvals ...interface{}) string {
|
||||||
|
if len(keyvals) == 0 {
|
||||||
|
return msg
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(msg, keyvals...)
|
||||||
|
}
|
||||||
|
|
||||||
func (logger *AppLogger) testingLog(msg string, keyvals ...interface{}) {
|
func (logger *AppLogger) testingLog(msg string, keyvals ...interface{}) {
|
||||||
if logger.testingLogger == nil {
|
if logger.testingLogger == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(keyvals) == 0 {
|
msg = format(msg, keyvals...)
|
||||||
logger.testingLogger.Log(msg)
|
logger.testingLogger.Logf(msg)
|
||||||
return
|
|
||||||
}
|
|
||||||
logger.testingLogger.Logf(msg, keyvals...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *AppLogger) Info(ctx sdk.Context, msg string, keyvals ...interface{}) {
|
func (logger *AppLogger) Info(ctx sdk.Context, msg string, keyvals ...interface{}) {
|
||||||
logger.testingLog(globalApplicationLoggerTag+msg, keyvals...)
|
msg = format(msg, keyvals...)
|
||||||
ctx.Logger().Info(globalApplicationLoggerTag+msg, keyvals...)
|
logger.testingLog(globalApplicationLoggerTag + msg)
|
||||||
|
ctx.Logger().Info(globalApplicationLoggerTag + msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *AppLogger) Debug(ctx sdk.Context, msg string, keyvals ...interface{}) {
|
func (logger *AppLogger) Debug(ctx sdk.Context, msg string, keyvals ...interface{}) {
|
||||||
logger.testingLog(globalApplicationLoggerTag+msg, keyvals...)
|
msg = format(msg, keyvals...)
|
||||||
ctx.Logger().Debug(globalApplicationLoggerTag+msg, keyvals...)
|
logger.testingLog(globalApplicationLoggerTag + msg)
|
||||||
|
ctx.Logger().Debug(globalApplicationLoggerTag + msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *AppLogger) Error(ctx sdk.Context, msg string, keyvals ...interface{}) {
|
func (logger *AppLogger) Error(ctx sdk.Context, msg string, keyvals ...interface{}) {
|
||||||
logger.testingLog(globalApplicationLoggerTag+msg, keyvals...)
|
msg = format(msg, keyvals...)
|
||||||
ctx.Logger().Error(globalApplicationLoggerTag+msg, keyvals...)
|
logger.testingLog(globalApplicationLoggerTag + msg)
|
||||||
|
ctx.Logger().Error(globalApplicationLoggerTag + msg)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user