[Python-Dev] Re: PEP 282 comments

Trent Mick trentm@ActiveState.com
2002年3月21日 19:37:47 -0800


So the decision is between the simpler:
 class Logger:
 def info(self, msg, *args): ...
 
 def exception(self, msg, *args):
 """Log sys.exc_info() at the ERROR level"""
and the slightly more complex:
 class Logger:
 def info(self, msg, *args, **kwargs):
 """Use kwargs["exc_info"] to log an exception at this level."""
 def exception(self, msg, *args, **kwargs):
 """Optionally pass in kwargs["exc_info"] otherwise sys.exc_info()
 is called to log exception information at the ERROR level."""
The argument for the latter is that is adds the capability of:
 (1) Logging an exception at a level other than ERROR (for which Jeremy
 maintains there is a string use case and for which Kevin Butler gives
 a simpler use case); and
 (2) Optionally explicitly passing in exc_info, that may differ from
 sys.exc_info().
 
The argument for the former is:
 (1) KISS and YAGNI
 (2) You should just be able to subclass Logger and add the functionality
 you want. This is only a string point if the given use cases are not
 at all common.
 (3) If you want to pass in exc_info other than sys.exc_info() then
 format it yourself or subclass Logger.
Thoughts?
Trent
-- 
Trent Mick
TrentM@ActiveState.com

AltStyle によって変換されたページ (->オリジナル) /