ccu._cli._utils

Utilities for CLI commands.

class ccu._cli._utils.FancyConsoleHandler(stream=None)[source]

Bases: StreamHandler

A handler that prints colourful output to stderr.

Initialize the handler.

If stream is not specified, sys.stderr is used.

emit(record: LogRecord)[source]

Emit a record using click.secho.

If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline in ANSI colours depending on the log level. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

ccu._cli._utils.configure_logging(console_log_level: int = 30) None[source]

Configure logging and printing for command-line functions.

The log file an dare read from the SETTINGS values. In particular,

Parameters:

console_log_level – The log level for messages printed to the console. Defaults to logging.WARNING.