Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def format(self, record):
msg = super(CustomFormatter, self).format(record)
return self._pattern.sub(r'%s\1%s' % (escape_codes['cyan'], escape_codes['reset']), msg) + escape_codes['reset']
file_handler.setFormatter(file_formatter)
self._logger.addHandler(file_handler)
self._outlog = file_handler.stream
# Default logging level.
self._logger.setLevel(logging.INFO)
# Special handling for Pyro4: turn off its handler b/c we have ours.
logging.getLogger('Pyro4').addHandler(logging.NullHandler())
# Console logger.
if console:
stream_handler = colorlog.StreamHandler()
# Don't send color codes inside Emacs shell buffers.
if os.environ['TERM'] != 'dumb':
colorlog.escape_codes['lightgreen'] = '\x1b[2m\x1b[32m'
stream_handler.setFormatter(colorlog.ColoredFormatter(
'%(log_color)s%(asctime)s [%(levelname)s] %(message)s',
log_colors={
'DEBUG' : 'lightgreen',
'INFO' : 'green',
'WARNING' : 'yellow',
'ERROR' : 'red',
'CRITICAL' : 'red,bg_white',
},
style='%'
))
else:
stream_handler.setFormatter(colorlog.ColoredFormatter(
'%(asctime)s [%(levelname)s] %(message)s',
))
self._logger.addHandler(stream_handler)
def format(self, record):
msg = super(CustomFormatter, self).format(record)
return self._pattern.sub(r'%s\1%s' % (escape_codes['cyan'], escape_codes['reset']), msg) \
+ escape_codes['reset']