Treasury Analytics Core
  • Home
  • API Reference
  • Examples
  • Credentials
  • Global Settings
  1. API Reference
  2. Utilities
  3. logging
  • Overview
    • Treasury Analytics Core
  • Credential Management
    • Secure Credential Management
    • Global Settings
  • Examples
    • Example Projects
  • API Reference
    • Function reference
    • Core Components
      • FinanceDataEngine
      • engine_factory
      • engine
      • database
      • cache
      • processor
      • analyzer
    • Configuration
      • settings
      • settings_factory
      • global_settings_manager
    • Utilities
      • credentials
      • dataframe_utils
      • setup_logging
      • env_checker
      • query_timer
      • setup_helper
      • logging
      • constants
      • types
    • Scripts
      • configure_db
      • create_project
      • manage_settings

On this page

  • logging
    • Classes
      • ErrorHandler
    • Functions
      • create_table
      • format_db_error
      • format_error_message
      • get_simplified_traceback
      • handle_exception
      • print_panel
      • set_trace_detail
      • setup_logging

Other Formats

  • Github (GFM)
  1. API Reference
  2. Utilities
  3. logging

logging

utils.logging

Logging configuration using Rich with improved error handling.

Classes

Name Description
ErrorHandler Error handling helper with consistent panel formatting.

ErrorHandler

utils.logging.ErrorHandler()

Error handling helper with consistent panel formatting.

Methods

Name Description
print_db_error Print a formatted database error.
print_error Print an error with consistent panel formatting.
show_details Get current detail display setting.
toggle_details Toggle or set whether to show detailed error traces.
print_db_error
utils.logging.ErrorHandler.print_db_error(
    console,
    error,
    query_name=None,
    params=None,
    show_traceback=None,
)

Print a formatted database error.

Parameters
Name Type Description Default
console Console Rich console required
error Exception The error to print required
query_name str Name of the query that caused the error, by default None None
params dict Query parameters, by default None None
show_traceback bool Whether to show traceback, overrides global setting, by default None None
print_error
utils.logging.ErrorHandler.print_error(
    console,
    error,
    title='Error',
    show_traceback=None,
    **context,
)

Print an error with consistent panel formatting.

Parameters
Name Type Description Default
console Console Rich console required
error Exception The error to print required
title str Error title, by default โ€œErrorโ€ 'Error'
show_traceback bool Whether to show traceback, overrides global setting, by default None None
**context dict Additional context to display {}
show_details
utils.logging.ErrorHandler.show_details()

Get current detail display setting.

Returns
Name Type Description
bool Whether showing detailed traces
toggle_details
utils.logging.ErrorHandler.toggle_details(show_details=None)

Toggle or set whether to show detailed error traces.

Parameters
Name Type Description Default
show_details bool If provided, set to this value, otherwise toggle, by default None None
Returns
Name Type Description
bool New state

Functions

Name Description
create_table Create a Rich table with specified columns.
format_db_error Format database errors into readable messages.
format_error_message Format any error into a readable message.
get_simplified_traceback Get a simplified traceback showing only user code.
handle_exception Custom exception handler for uncaught exceptions with consistent formatting.
print_panel Print content inside a panel.
set_trace_detail Set whether to show detailed stack traces.
setup_logging Set up logging with Rich console output.

create_table

utils.logging.create_table(title, columns)

Create a Rich table with specified columns.

Parameters

Name Type Description Default
title str Table title required
columns list[tuple[str, str, str]] List of tuples (column_name, style, justify) required

Returns

Name Type Description
Table Rich table

format_db_error

utils.logging.format_db_error(error, query_name=None, params=None)

Format database errors into readable messages.

Parameters

Name Type Description Default
error Exception The original exception required
query_name str Name of the query that caused the error, by default None None
params dict Query parameters, by default None None

Returns

Name Type Description
str Formatted error message

format_error_message

utils.logging.format_error_message(error, error_type='Error', **context)

Format any error into a readable message.

Parameters

Name Type Description Default
error Exception The error to format required
error_type str Type of error, by default โ€œErrorโ€ 'Error'
**context dict Additional context information {}

Returns

Name Type Description
str Formatted error message

get_simplified_traceback

utils.logging.get_simplified_traceback(exc_traceback)

Get a simplified traceback showing only user code.

Parameters

Name Type Description Default
exc_traceback TracebackType Exception traceback required

Returns

Name Type Description
list List of frame information tuples

handle_exception

utils.logging.handle_exception(exc_type, exc_value, exc_traceback)

Custom exception handler for uncaught exceptions with consistent formatting.

print_panel

utils.logging.print_panel(console, content, title)

Print content inside a panel.

Parameters

Name Type Description Default
console Console Rich console required
content Any Content to display required
title str Panel title required

set_trace_detail

utils.logging.set_trace_detail(show_details)

Set whether to show detailed stack traces.

setup_logging

utils.logging.setup_logging(settings=None)

Set up logging with Rich console output.

Parameters

Name Type Description Default
settings dict Logging settings, by default None None

Returns

Name Type Description
tuple[logging.Logger, Console] Configured logger and console
setup_helper
constants
 
 
  • Built with [Quarto](https://quarto.org/) and [quartodoc](https://machow.github.io/quartodoc/)