crossbar._logging

Attributes

Classes

JSON

An object which encapsulates a JSON-dumpable item, and will colorise it

LogCapturer

A context manager that captures logs inside of it, and makes it available

_Fore

Functions

color_json(json_str)

Given an already formatted JSON string, return a colored variant which will

escape_formatting(text)

Escape things that would otherwise confuse .format.

make_JSON_observer(outFile)

Make an observer which writes JSON to C{outfile}.

make_logfile_observer(path[, show_source])

Make an observer that writes out to C{path}.

make_stderr_observer([levels, show_source, format, ...])

Create an observer which prints logs to L{sys.stderr}.

make_stdout_observer([levels, show_source, format, ...])

Create an observer which prints logs to L{sys.stdout}.

strip_ansi(text)

Strip ANSI codes.

Module Contents

class JSON(item)[source]

Bases: object

An object which encapsulates a JSON-dumpable item, and will colorise it when it is __str__’d.

__str__()[source]
_item[source]
class LogCapturer(level='debug')[source]

Bases: object

A context manager that captures logs inside of it, and makes it available through the logs attribute, or the get_category method.

__enter__()[source]
__exit__(type, value, traceback)[source]
_got_log(log)[source]
_old_log_level[source]
_out_observer[source]
desired_level = 'debug'[source]
get_category(identifier)[source]

Get logs captured with the given log category.

log_text[source]
logs = [][source]
NONE_FORMAT = '{text}'[source]
STANDARD_FORMAT = '{startcolor}{time} [{system}]{endcolor} {text}'[source]
SYSLOGD_FORMAT = '{startcolor}[{system}]{endcolor} {text}'[source]
class _Fore[source]

Bases: object

BLACK = ''[source]
BLUE = ''[source]
CYAN = ''[source]
GREEN = ''[source]
LIGHTBLACK_EX = ''[source]
LIGHTBLUE_EX = ''[source]
LIGHTCYAN_EX = ''[source]
LIGHTGREEN_EX = ''[source]
LIGHTMAGENTA_EX = ''[source]
LIGHTRED_EX = ''[source]
LIGHTWHITE_EX = ''[source]
LIGHTYELLOW_EX = ''[source]
MAGENTA = ''[source]
RED = ''[source]
RESET = ''[source]
WHITE = ''[source]
YELLOW = ''[source]
_ansi_cleaner[source]
cb_logging_aware = 'CROSSBAR_RICH_LOGGING_ENABLE=True'[source]
color_json(json_str)[source]

Given an already formatted JSON string, return a colored variant which will produce colored output on terminals.

escape_formatting(text)[source]

Escape things that would otherwise confuse .format.

make_JSON_observer(outFile)[source]

Make an observer which writes JSON to C{outfile}.

make_logfile_observer(path, show_source=False)[source]

Make an observer that writes out to C{path}.

make_stderr_observer(levels=(LogLevel.warn, LogLevel.error, LogLevel.critical), show_source=False, format='standard', color=False, _file=None, _categories=None)[source]

Create an observer which prints logs to L{sys.stderr}.

make_stdout_observer(levels=(LogLevel.info,), show_source=False, format='standard', trace=False, color=False, _file=None, _categories=None)[source]

Create an observer which prints logs to L{sys.stdout}.

record_separator = '\x1e'[source]
strip_ansi(text)[source]

Strip ANSI codes.