Message153493
| Author |
vinay.sajip |
| Recipients |
jimlekas, vinay.sajip |
| Date |
2012年02月16日.19:13:54 |
| SpamBayes Score |
4.9348287e-08 |
| Marked as misclassified |
No |
| Message-id |
<1329419635.45.0.216607108209.issue14024@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
A number of points:
1. exc_text is not just an implementation detail - it's in the docs. Thus, removing the cache altogether would be backwards-incompatible.
2. The exc_text value is the only simple way of propagating the exception information across the wire, which is a common use case (e.g SocketHandler).
3. This is not a "behavior" issue, as the behaviour is by design and documented.
4. What's wrong with the following approach?
class NoStackTraceFormatter(logging.Formatter):
def formatException(self, exc_info): # Don't emit the stack trace
return '\n'.join(traceback.format_exception_only(exc_info[0], exc_info[1])) # type and value only
def format(self, record):
saved_exc_text = record.exc_text # optional
record.exc_text = None
result = super(NoStackTraceFormatter, self).format(record)
record.exc_text = saved_exc_text # or None, if you want
return result
You can either save and restore the previous exc_text value, or set it to None after the parent class operation - this will cause it to be always recomputed by the next handler. This way, a handler which needs abbreviated information always gets it, but other handlers append the full stack trace.
I'm closing this as I believe my suggestion shows a way of subclassing and overriding which works. You can re-open if you think I've missed something. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年02月16日 19:13:55 | vinay.sajip | set | recipients:
+ vinay.sajip, jimlekas |
| 2012年02月16日 19:13:55 | vinay.sajip | set | messageid: <1329419635.45.0.216607108209.issue14024@psf.upfronthosting.co.za> |
| 2012年02月16日 19:13:54 | vinay.sajip | link | issue14024 messages |
| 2012年02月16日 19:13:54 | vinay.sajip | create |
|