How to use the watchmaker.logger.prepare_logging function in watchmaker

To help you get started, we’ve selected a few watchmaker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plus3it / watchmaker / tests / test_logger.py View on Github external
def test_logger_handler():
    """
    Tests prepare_logging() use case.

    Tests that prepare_logging() will set logger level appropriately, attach a
    FileHandler if a directory is passed, and set log file to the correct mode.
    """
    logger.prepare_logging('logfiles', 'debug')
    this_logger = logging.getLogger()

    if logger.HAS_PYWIN32:
        log_hdlr = this_logger.handlers.pop()
        assert isinstance(log_hdlr, logging.handlers.NTEventLogHandler)
        assert log_hdlr.level == logging.DEBUG

    log_hdlr = this_logger.handlers.pop()
    assert isinstance(log_hdlr, logging.FileHandler)
    assert log_hdlr.level == logging.DEBUG

    assert oschmod.get_mode(
        os.path.join('logfiles', 'watchmaker.log')) == 0o600
github plus3it / watchmaker / tests / test_logger.py View on Github external
def test_log_if_no_log_directory_given(caplog):
    """
    Tests prepare_logging() use case.

    Tests that not passing in a path to a logging directory will
    produce a logging message.
    """
    logger.prepare_logging(None, 'info')
    assert 'Watchmaker will not be logging to a file!' in caplog.text
github plus3it / watchmaker / src / watchmaker / cli.py View on Github external
def main(extra_arguments=None, **kwargs):
    """Entry point for Watchmaker cli."""
    prepare_logging(kwargs['log_dir'], kwargs['log_level'])

    sys.excepthook = exception_hook

    watchmaker_arguments = watchmaker.Arguments(**dict(
        extra_arguments=extra_arguments,
        **kwargs
    ))
    watchmaker_client = watchmaker.Client(watchmaker_arguments)
    sys.exit(watchmaker_client.install())