def set_detailed_logs(detailed): """Set or unset the shell logs to detailed.""" global shell_handler color = has_color_support(sys.stdout) formatter = DetailedFormatter(color) \ if detailed else CustomFormatter(color) shell_handler.setFormatter(formatter)
"""Inject the data in the log message. msg (string): the message given to one of debug(), info(), warning(), etc. methods. kwargs (dict): the keyword arguments given to such method (not the positional ones!). """ kwargs.setdefault("extra", {}).setdefault("operation", self.operation) return msg, kwargs # Get the root logger. root_logger = logging.getLogger() root_logger.setLevel(logging.DEBUG) # Install a shell handler. shell_handler = StreamHandler(sys.stdout) shell_handler.setLevel(logging.INFO) shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stdout))) root_logger.addHandler(shell_handler) def set_detailed_logs(detailed): """Set or unset the shell logs to detailed.""" global shell_handler color = has_color_support(sys.stdout) formatter = DetailedFormatter(color) \ if detailed else CustomFormatter(color) shell_handler.setFormatter(formatter)
msg (string): the message given to one of debug(), info(), warning(), etc. methods. kwargs (dict): the keyword arguments given to such method (not the positional ones!). """ kwargs.setdefault("extra", {}).setdefault("operation", self.operation) return msg, kwargs # Get the root logger. root_logger = logging.getLogger() root_logger.setLevel(logging.DEBUG) # Install a shell handler. shell_handler = StreamHandler(sys.stdout) shell_handler.setLevel(logging.INFO) shell_handler.setFormatter(CustomFormatter(has_color_support(sys.stdout))) root_logger.addHandler(shell_handler) def set_detailed_logs(detailed): """Set or unset the shell logs to detailed.""" global shell_handler color = has_color_support(sys.stdout) formatter = DetailedFormatter(color) \ if detailed else CustomFormatter(color) shell_handler.setFormatter(formatter)