logging: Print stack trace in case of errors.

fixes #1827
This commit is contained in:
Krishna Srinivas
2016-08-25 22:09:01 +05:30
committed by Harshavardhana
parent 37cbcae6ba
commit 9358ee011b
38 changed files with 485 additions and 311 deletions
+3 -2
View File
@@ -67,9 +67,10 @@ func errorIf(err error, msg string, data ...interface{}) {
fields := logrus.Fields{
"cause": err.Error(),
}
if globalTrace {
fields["stack"] = "\n" + stackInfo()
if e, ok := err.(*Error); ok {
fields["stack"] = strings.Join(e.Trace(), " ")
}
log.WithFields(fields).Errorf(msg, data...)
}