Coverage for /private/tmp/im/impacket/impacket/examples/logger.py : 24%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved. # # This software is provided under under a slightly modified version # of the Apache Software License. See the accompanying LICENSE file # for more information. # # Description: This logger is intended to be used by impacket instead # of printing directly. This will allow other libraries to use their # custom logging implementation. #
# This module can be used by scripts using the Impacket library # in order to configure the root logger to output events # generated by the library with a predefined format
# If the scripts want to generate log entries, they can write # directly to the root logger (logging.info, debug, etc).
''' Prefixing logged messages through the custom attribute 'bullet'. ''' logging.Formatter.__init__(self,'%(bullet)s %(message)s', None)
if record.levelno == logging.INFO: record.bullet = '[*]' elif record.levelno == logging.DEBUG: record.bullet = '[+]' elif record.levelno == logging.WARNING: record.bullet = '[!]' else: record.bullet = '[-]'
return logging.Formatter.format(self, record)
# We add a StreamHandler and formatter to the root logger handler = logging.StreamHandler(sys.stdout) handler.setFormatter(ImpacketFormatter()) logging.getLogger().addHandler(handler) logging.getLogger().setLevel(logging.INFO) |