Source code for switchyard.lib.logging

import logging

from ..textcolor import *
from .debugging import debugger

def setup_logging(debug):
    Setup logging format and log level.
    if debug:
        level = logging.DEBUG
        level = logging.INFO
    logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=level)

[docs]def log_failure(s): '''Convenience function for failure message.''' with red(): logging.fatal("{}".format(s))
[docs]def log_debug(s): '''Convenience function for debugging message.''' logging.debug("{}".format(s))
[docs]def log_warn(s): '''Convenience function for warning message.''' with magenta(): logging.warning("{}".format(s))
[docs]def log_info(s): '''Convenience function for info message.'''"{}".format(s))