fix(server): Ensure error messages are correctly printed in logs

I assumed (incorrectly) that logrus would already take care of
surfacing error messages in human-readable form.
This commit is contained in:
Vincent Ambo 2019-10-28 18:20:04 +01:00 committed by Vincent Ambo
parent 790bce219c
commit c08aa52558

View file

@ -76,6 +76,13 @@ func (f stackdriverFormatter) Format(e *log.Entry) ([]byte, error) {
msg["eventTime"] = &e.Time msg["eventTime"] = &e.Time
msg["severity"] = logSeverity(e.Level) msg["severity"] = logSeverity(e.Level)
if err, ok := msg[log.ErrorKey]; ok {
// TODO(tazjin): Cast safely - for now there should be
// no calls to `.WithError` with a nil error, but who
// knows.
msg[log.ErrorKey] = (err.(error)).Error()
}
if isError(e) { if isError(e) {
loc := reportLocation{ loc := reportLocation{
FilePath: e.Caller.File, FilePath: e.Caller.File,