Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)

        def add_logging(console_debug=False):
    import logging.handlers

    LEVELS = {'debug': logging.DEBUG,
            'info': logging.INFO,
            'warning': logging.WARNING,
            'error': logging.ERROR,
            'critical': logging.CRITICAL}

#TODO: load logger settings from config file
    logger = logging.getLogger("ANK")
    logger.setLevel(logging.DEBUG)

#TODO: check settings are being loaded from file correctly
# and that handlers are being correctly set - as default level appearing

    ch = logging.StreamHandler()
    if console_debug:
        level = logging.DEBUG # User specified debug level
    else:
# Use debug from settings
        level = LEVELS.get(settings['Logging']['Console']['Level'])

    format_string = '%(levelname)-6s %(message)s'
    if level == logging.DEBUG:
# Include module name in debugging output
        format_string = "%(module)s\t" + format_string
    if settings['Logging']['Console']['Timestamp']:
        format_string = "%(asctime)s " + format_string

    formatter = logging.Formatter(format_string)

    ch.setLevel(level)
    #ch.setLevel(logging.INFO)

    ch.setFormatter(formatter)

    logging.getLogger('').addHandler(ch)

    LOG_FILENAME =  os.path.join(log_dir, "autonetkit.log")
    LOG_SIZE = 2097152 # 2 MB
    fh = logging.handlers.RotatingFileHandler(
                LOG_FILENAME, maxBytes=LOG_SIZE, backupCount=5)

    level = LEVELS.get(settings['Logging']['File']['Level'])

    fh.setLevel(level)
    formatter = logging.Formatter("%(asctime)s %(levelname)s "
                                "%(funcName)s %(message)s")
    fh.setFormatter(formatter)

    logging.getLogger('').addHandler(fh)
        


src/a/n/ank_le-HEAD/AutoNetkit/console_script.py   ank_le(Download)
 
    options, arguments = opt.parse_args()
    config.add_logging(console_debug = options.debug)
 
#### Main code 

src/a/n/ank_le-HEAD/AutoNetkit/collect_data.py   ank_le(Download)
 
    options, arguments = opt.parse_args()
    config.add_logging(console_debug = options.debug)
 
#### Main code 

src/a/n/ank_le-HEAD/AutoNetkit/tests/test.py   ank_le(Download)
def test_config():
    from AutoNetkit import config
    config.add_logging()