diff --git a/log.go b/log.go index 2a4867f..62b8df2 100644 --- a/log.go +++ b/log.go @@ -70,12 +70,22 @@ func (log *Logger) SetLogLevel(newlv logLevel) (oldlv logLevel) { } func (log *Logger) Print(prefix string, v interface{}) { - preety, _ := json.Marshal(v) - log.logwrite(DEBUG, 3, prefix+"%s\n", preety) + var str = "" + 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{}) { - 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) }