/usr/lib/python3/dist-packages/cookiecutter/log.py is in python3-cookiecutter 1.6.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # -*- coding: utf-8 -*-
import logging
import sys
LOG_LEVELS = {
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
'WARNING': logging.WARNING,
'ERROR': logging.ERROR,
'CRITICAL': logging.CRITICAL,
}
LOG_FORMATS = {
'DEBUG': u'%(levelname)s %(name)s: %(message)s',
'INFO': u'%(levelname)s: %(message)s',
}
def configure_logger(stream_level='DEBUG', debug_file=None):
# Set up 'cookiecutter' logger
logger = logging.getLogger('cookiecutter')
logger.setLevel(logging.DEBUG)
# Remove all attached handlers, in case there was
# a logger with using the name 'cookiecutter'
del logger.handlers[:]
# Create a file handler if a log file is provided
if debug_file is not None:
debug_formatter = logging.Formatter(LOG_FORMATS['DEBUG'])
file_handler = logging.FileHandler(debug_file)
file_handler.setLevel(LOG_LEVELS['DEBUG'])
file_handler.setFormatter(debug_formatter)
logger.addHandler(file_handler)
# Get settings based on the given stream_level
log_formatter = logging.Formatter(LOG_FORMATS[stream_level])
log_level = LOG_LEVELS[stream_level]
# Create a stream handler
stream_handler = logging.StreamHandler(stream=sys.stdout)
stream_handler.setLevel(log_level)
stream_handler.setFormatter(log_formatter)
logger.addHandler(stream_handler)
return logger
|