lector.log#
Helpers to pretty print/log objects using Rich.
Classes#
A custom formatter controlling message color. |
Functions#
|
|
|
Pretty format any object, if possible with Rich. |
|
|
|
Make a rich view for an arrow schema diff. |
|
Make a rich view for arrow schema. |
|
Ensure logging handler is only added once. |
|
Pyarrow table to rich table. |
|
Rich track with elapsed time by default. |
|
More compact strinf represenation of arrow data types. |
Attributes#
Shortcut for inline formatting, avoiding strings terminating in line breaks. |
- class lector.log.ColoredFormatter(datefmt=None, validate=True)[source]#
Bases:
logging.FormatterA custom formatter controlling message color.
- FORMAT = Multiline-String[source]#
Show Value
"""<COL>{asctime} {levelname} | {name} | {module}.{funcName}:{lineno}<RESET> {message}"""
- format(record)[source]#
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- lector.log.dict_view(d, title='', expand=False, width=None, padding=1, **kwds)[source]#
- Parameters:
d (dict) –
title (str) –
expand (bool) –
- Return type:
rich.panel.Panel
- lector.log.pformat(obj, console=None, markup=True, end='', strip=False, **kwargs)[source]#
Pretty format any object, if possible with Rich.
- lector.log.schema_comparison(s1, s2, title=None, padding=1, left='Before', right='After')[source]#
- Parameters:
s1 (pyarrow.Schema) –
s2 (pyarrow.Schema) –
title (str | None) –
padding (int) –
left (str) –
right (str) –
- lector.log.schema_diff_view(diff, title=None, padding=1)[source]#
Make a rich view for an arrow schema diff.
- Parameters:
diff (dict) –
title (str | None) –
padding (int) –
- Return type:
rich.table.Table
- lector.log.schema_view(schema, title='Schema', padding=1)[source]#
Make a rich view for arrow schema.
- Parameters:
schema (pyarrow.Schema) –
title (str | None) –
padding (int) –
- Return type:
rich.table.Table
- lector.log.setup_logging(level=logging.DEBUG, color=True)[source]#
Ensure logging handler is only added once.
- lector.log.table_view(tbl, title=None, n_rows_max=10, n_columns_max=6, max_column_width=20, padding=1)[source]#
Pyarrow table to rich table.
- Parameters:
tbl (pyarrow.Table) –
title (str | None) –
n_rows_max (int) –
n_columns_max (int) –
max_column_width (int) –
padding (int) –
- Return type:
rich.table.Table
- lector.log.track(items, columns=None, total=None, desc='Processing', update_period=0.1, **kwds)[source]#
Rich track with elapsed time by default.
- Parameters:
items (collections.abc.Iterable[Item] | collections.abc.Sequence[Item]) –
columns (collections.abc.Iterable[rich.table.Column] | None) –
total (float | None) –
desc (str) –
update_period (float) –
- Return type:
collections.abc.Iterable[Item]