click-log
click-log copied to clipboard
Not clear on setting file handler and format
Only getting unformatted console output when I try this. I'll be happy to submit some updated docs if you can help me through this:D
`import click import click_log import logging
logger = logging.getLogger(name)
fh = logging.FileHandler(name + '.log') formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) logger.addHandler(fh)
click_log.basic_config(logger)
@click.command() @click_log.simple_verbosity_option(default='DEBUG', metavar='LEVEL') @click.option('--execution_mode', default='dry_run', help="mode: [dry_run/install/force]") def main(execution_mode, phase, load_local_files): logger.info("beginning with execution mode: " + execution_mode)`
Hi, use the ColorFormatter on your filehandler.
Also note that basic_config
will replace all of your handlers with the ClickHandler, so I would first call basic_config and then set up your additional handler.