logging_utilities Module

Utility module for logging.

Functions

function_debug_log_wrapped

Add logs wrapper around transformer class function.

function_debug_log_wrapped(log_level: int = 10) -> Callable[[Callable[[...], Any]], Callable[[...], Any]]

Parameters

Name Description
log_level
default value: 10

get_logger

Create the logger with telemetry hook.

get_logger(namespace: str | None = None, filename: str | None = None, verbosity: int = 10, extra_handlers: List[Handler] | None = None, component_name: str | None = None) -> Logger

Parameters

Name Description
namespace

The namespace for the logger

default value: None
filename

log file name

default value: None
verbosity

logging verbosity

default value: 10
extra_handlers

any extra handlers to attach to the logger

default value: None
component_name

component name

default value: None

Returns

Type Description

logger if log file name and namespace are provided otherwise null logger

is_exception_stacktrace_loggable

is_exception_stacktrace_loggable() -> bool

is_non_automl_exception_allowed

is_non_automl_exception_allowed(exception: BaseException) -> bool

Parameters

Name Description
exception
Required

is_path_allowed

is_path_allowed(exception_path: str) -> bool

Parameters

Name Description
exception_path
Required

is_stdlib_module

Determine whether this is a module shipped with Python.

is_stdlib_module(exception_path: str) -> bool

Parameters

Name Description
exception_path
Required

log_activity

Log the activity status with duration.

log_activity(logger: Logger, activity_name: str, activity_type: str | None = None, custom_dimensions: Dict[str, Any] | None = None) -> Iterator[Any | None]

Parameters

Name Description
logger
Required

logger

activity_name
Required

activity name

activity_type
Required

activity type

custom_dimensions
Required

custom dimensions

log_system_info

Log cpu, memory and OS info.

log_system_info(logger: Logger, prefix_message: str = '') -> None

Parameters

Name Description
logger
Required

logger object

prefix_message
Required

string that in the prefix in the log

Returns

Type Description

None

log_traceback

Log exception traces.

log_traceback(exception: BaseException, logger: Logger | LoggerAdapter | None, override_error_msg: str | None = None, is_critical: bool | None = True, tb: Any | None = None) -> None

Parameters

Name Description
exception
Required

The exception to log.

logger
Required

The logger to use.

override_error_msg

The message to display that will override the current error_msg.

default value: None
is_critical

If is_critical, the logger will use log.critical, otherwise log.error.

default value: True
tb

The traceback to use for logging; if not provided, the one attached to the exception is used.

default value: None

mark_package_exceptions_as_loggable

mark_package_exceptions_as_loggable(module: module) -> None

Parameters

Name Description
module
Required

mark_path_as_loggable

mark_path_as_loggable(path: str) -> None

Parameters

Name Description
path
Required

mark_path_as_not_loggable

mark_path_as_not_loggable(path: str) -> None

Parameters

Name Description
path
Required

remove_blacklisted_logging_keys_from_dict

Recursively remove the key from a dict.

remove_blacklisted_logging_keys_from_dict(dict_obj: Dict[str, Any]) -> None

Parameters

Name Description
dict_obj
Required

remove_blacklisted_logging_keys_from_json_str

Recursively remove the key from a json str and return a json str.

remove_blacklisted_logging_keys_from_json_str(json_str: str) -> str

Parameters

Name Description
json_str
Required