haive.core.utils.debugkit.logging.structuredΒΆ

Enhanced Logging Utilities

Provides beautiful, structured logging with Rich integration, context awareness, and development-friendly features.

ClassesΒΆ

DevLogger

Enhanced development logger with rich formatting and context.

RichFormatter

Custom formatter for non-Rich environments.

Module ContentsΒΆ

class haive.core.utils.debugkit.logging.structured.DevLogger(name='haive.dev')[source]ΒΆ

Enhanced development logger with rich formatting and context.

Parameters:

name (str)

context(name, **kwargs)[source]ΒΆ

Context manager for adding context to logs.

Parameters:

name (str)

critical(message, exception=None, **kwargs)[source]ΒΆ

Log critical message with optional exception.

Parameters:
Return type:

None

debug(message, **kwargs)[source]ΒΆ

Log debug message with context.

Parameters:

message (str)

Return type:

None

divider(text='', style='blue')[source]ΒΆ

Print a divider line.

Parameters:
Return type:

None

error(message, exception=None, **kwargs)[source]ΒΆ

Log error message with optional exception.

Parameters:
Return type:

None

info(message, **kwargs)[source]ΒΆ

Log info message with context.

Parameters:

message (str)

Return type:

None

json(data, title='JSON Data')[source]ΒΆ

Log data as formatted JSON.

Parameters:
  • data (Any)

  • title (str)

Return type:

None

metrics(metrics, title='Metrics')[source]ΒΆ

Log metrics in a formatted way.

Parameters:
Return type:

None

panel(message, title='Message', style='blue')[source]ΒΆ

Log message in a panel.

Parameters:
Return type:

None

progress(message, **kwargs)[source]ΒΆ

Log progress message.

Parameters:

message (str)

Return type:

None

set_level(level)[source]ΒΆ

Set logging level.

Parameters:

level (str | int)

Return type:

None

success(message, **kwargs)[source]ΒΆ

Log success message.

Parameters:

message (str)

Return type:

None

table(data, title='Data')[source]ΒΆ

Log data as a formatted table.

Parameters:
Return type:

None

timer(name)[source]ΒΆ

Context manager for timing operations.

Parameters:

name (str)

timer_end(name)[source]ΒΆ

End a timer and log duration.

Parameters:

name (str)

Return type:

float

timer_start(name)[source]ΒΆ

Start a timer.

Parameters:

name (str)

Return type:

None

warning(message, **kwargs)[source]ΒΆ

Log warning message with context.

Parameters:

message (str)

Return type:

None

class haive.core.utils.debugkit.logging.structured.RichFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]ΒΆ

Bases: logging.Formatter

Custom formatter for non-Rich environments.

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of β€˜%’, β€˜{’ or β€˜$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

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.