Package: conlog
Anti-Boilerplate Console Logging Module for PythonAboutconlogis a configurable console logging mechanism featuring:Boilerplate-free setupOnly one line per LoggerExport to optional rotating log fileShow additional log columns when debugging, suppress when notYAML or argument based configurationInstallationInstall via pip:(Recommended)pip install conlogOr with setup_tools:python setup.py installDocumentationQuick startimport conlog
log = conlog.start(level='INFO')
log.info('Hello World!')Functionsstart(…)start(
    yaml_file=None,
    log_file=None,
    log_format='%(asctime)22s - %(levelname)8s - %(name)20s - %(message)s',
    debug_format='%(asctime)22s - %(levelname)8s - %(name)20s - %(funcName)20s - %(message)s',
    level='INFO',
    max_file_size='5000000',
    max_retention=5
)Configure and return the root Logger instance. All parameters
are optional. If any parameter is not supplied, its default
value be used. It is even possible to run with no parameters,
in which case the default values would be used across all
options.Parametersyaml_file:Pull configurations from YAML file. All parameters fromstart()are available as YAML options. Option entries
should be nested underconlogat the root of the YAML
file. The file should be structured:conlog:
  log_file: log/app.log
  log_format: '%(asctime)22s - %(levelname)8s - %(name)20s - %(message)s'
  debug_format: '%(asctime)22s - %(levelname)8s - %(name)20s - %(funcName)20s - %(message)s'
  level: INFO
  max_file_size: 5 MB
  max_retention: 5Likestart()parameters, all YAML settings are optional.
If any setting is not supplied in the configuration, its
default value will be used.Ifyaml_fileis supplied, its values are processed first,
and will be overridden by any additional parameters called instart()Default:Nonelog_file:Path to log file. By default, file logging is disabled. Iflog_fileis set to a file path, for example,log/app.log,
it will enable rotating file logging.NOTE: In the examplelog/app.log, the log file itself,app.log, does not need to exist; however, the base directorylogMUST exist.By default the log file will rotate when it reaches5 MB,
with up to5rotations being kept before overwriting the oldest.
These values can be adjusted using themax_file_sizeandmax_retentionoptions.Default:Nonelog_format:Logging format for all levels EXCEPTDEBUG.Default:%(asctime)22s - %(levelname)8s - %(name)20s - %(message)sdebug_format:Logging format forDEBUGlevel. By default, this displays the
same formatting asformat, but with an additional column for
the function name which is calling the Logger.Default:%(asctime)22s - %(levelname)8s - %(name)20s - %(funcName)20s - %(message)slevel:Logging level. Only messages sent to this level or higher will
appear in log.Default:INFOmax_file_size:Maximum log file size before rollover. This value can either
be an integer byte size or a proper string like:5 MB,50 kB, etc. Setting to0will cause the log file to
grow infinitely with no rollover. This option has no impact iflog_fileis set toNone.Default:5000000(5 MB)max_retention:Maximum number of rollover logs to keep. Rotated logs will be
saved in the formatlog_name.1,log_name.2, etc.,
untilmax_retentionis reached. At that point the oldest
of the rollover logs will be purged. This option has no impact
iflog_fileis set toNone, or ifmax_file_sizeis
set to0.Default:5new(inst)Get a new Logger instance for the calling class. Recommended
usage isself.log = conlog.new(self).Parametersinst:Instance of class which new Logger is for, (HINT: useself)RequiredExamplesThis is the easiest way to add a root Logger using conlog withINFOlevel
logging to the console.log = conlog.start(level='INFO')Start logging based on configuration in the YAML file,conf/conlog.yml.log = conlog.start(yaml_file='conf/conlog.yml')StartDEBUGlevel Logger with console logging and rotating file logging tologs/app.log.log = conlog.start(
        log_file='logs/app.log',
        level='DEBUG'
)Similar to above but with specific values set for rotation of log files. This
will rotate the log file when it reaches1 MBand retain up to10archived log files before overwriting the oldest.log = conlog.start(
        log_file='log/app.log',
        level='INFO',
        max_file_size='1 MB',
        max_retention=10,
)Start console logging with a different log format.log = conlog.start(log_format='%(levelname)s:%(name)s:%(message)s')Get a Logger instance for a class. (Remember tostart()first)class Example(object):
    def __init__(self):
        self.log = conlog.new(self)AuthorRyan Miller -ryan@devopsmachine.com