I would like to make custom logger methods either by a custom logging handlers or a custom logger class and dispatch the logging records to different targets.
For example:
log = logging.getLogger('application')
log.progress('time remaining %d sec' % i)
custom method for logging to:
- database status filed
- console custom handler showing changes in a single console line
log.data(kindOfObject)
custom method for logging to:
- database
- special data format
log.info
log.debug
log.error
log.critical
all standard logging methods:
- database status/error/debug filed
- console: append text line
- logfile
If I use a custom LoggerHandler by overriding the emit method, I can not distinguishe the level of the logging record. Is there any other posibility to get in runtime information of the record level?
class ApplicationLoggerHandler(logging.Handler):
def emit(self, record):
# at this place I need to know the level of the record (info, error, debug, critical)?
Any suggestions?