Logrus: adding WithStack() function

Created on 10 Jan 2018  路  3Comments  路  Source: sirupsen/logrus

I though about that in my projects that are using logrus,
I use to write the stack trace to important logs.
The way I do that now is:
logger.WithField("stack", string(debug.Stack())

but that is not a nice way of doing that, because I need to choose a key for that any time I want to add the stack trace to a log entry. I think it would be nice to add a function WithStack(), like WithError()

enhancement

Most helpful comment

I've added a small pull request because I think it would be a nice to have feature.

All 3 comments

Some error reporting systems, such as GCP Error Reporting, use the existence of a stack to decide whether a log entry is an error. Currently we have to do:

logger.WithError(err).Error("This is an error\n", string(debug.Stack()))

Which is a bit cumbersome.

I've added a small pull request because I think it would be a nice to have feature.

Closing per the project being put into maintenance mode

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SergeiVasilenko picture SergeiVasilenko  路  3Comments

salvador-dali picture salvador-dali  路  5Comments

kaushikchaubal picture kaushikchaubal  路  5Comments

Integralist picture Integralist  路  3Comments

UnAfraid picture UnAfraid  路  5Comments