v1.2.3 add error output when printpretty
This commit is contained in:
parent
d93e63ab09
commit
e27ea9f370
16
log.go
16
log.go
@ -70,12 +70,22 @@ func (log *Logger) SetLogLevel(newlv logLevel) (oldlv logLevel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (log *Logger) Print(prefix string, v interface{}) {
|
func (log *Logger) Print(prefix string, v interface{}) {
|
||||||
preety, _ := json.Marshal(v)
|
var str = ""
|
||||||
log.logwrite(DEBUG, 3, prefix+"%s\n", preety)
|
if pkg, err := json.Marshal(v); err != nil {
|
||||||
|
str = err.Error()
|
||||||
|
} else {
|
||||||
|
str = string(pkg)
|
||||||
|
}
|
||||||
|
log.logwrite(DEBUG, 3, prefix+"%s\n", str)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (log *Logger) PrintPretty(prefix string, v interface{}) {
|
func (log *Logger) PrintPretty(prefix string, v interface{}) {
|
||||||
preety, _ := json.MarshalIndent(v, "==", " ")
|
var preety = ""
|
||||||
|
if pkg, err := json.MarshalIndent(v, "==", " "); err != nil {
|
||||||
|
preety = err.Error()
|
||||||
|
} else {
|
||||||
|
preety = string(pkg)
|
||||||
|
}
|
||||||
log.logwrite(DEBUG, 3, prefix+"%s\n", preety)
|
log.logwrite(DEBUG, 3, prefix+"%s\n", preety)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user