leaf_engine.logging
Attributes
Functions
|
|
|
|
|
Decorator factory that allows adding arguments to the _log explicit |
|
|
|
|
|
Decorator factory that allows adding arguments to the log_shape explicit |
|
Decorator factory that allows adding arguments to the log_shape explicit |
|
Sets up local file and AWS CloudWatch log handlers. |
Module Contents
- leaf_engine.logging._get_file_handler(file_name: str, level=logging.INFO, mode='a')
- Parameters:
file_name (str) –
- leaf_engine.logging._get_log_path()
- leaf_engine.logging._get_stream_handler(level=logging.INFO)
- leaf_engine.logging.get_logger()
- leaf_engine.logging.log(*factory_args, **factory_kwargs)
Decorator factory that allows adding arguments to the _log explicit decorator below.
You can use this decorator to add arbitrary logging to any function that takes a pd.DataFrame as its first argument and returns a pd.DataFrame.
For example, to log the shape before and after an arbitrary function:
>>> @log(log_fn=lambda df: df.shape, level=logging.INFO) >>> def function(df): >>> return df
Or to specify custom input/output logging functions: >>> @log( >>> input_log_fn=lambda df: f”This is the input shape: {df.shape}”, >>> output_log_fn=lambda df: df[‘id’].value_counts(), >>> level=logging.INFO >>> ) >>> def function(df): >>> return df
- leaf_engine.logging.log_params(input_params: dict) None
- Parameters:
input_params (dict) –
- Return type:
None
- leaf_engine.logging.log_shape(*factory_args, **factory_kwargs)
Decorator factory that allows adding arguments to the log_shape explicit decorator below.
- leaf_engine.logging.log_spend(*factory_args, **factory_kwargs)
Decorator factory that allows adding arguments to the log_shape explicit decorator below.
- leaf_engine.logging.setup_logger(file_name: str, cloudwatch: bool = True)
Sets up local file and AWS CloudWatch log handlers.
- leaf_engine.logging.DATE_FORMAT = '%Y-%m-%d %H:%M:%S%z'
- leaf_engine.logging.LOG_FORMAT = '[%(asctime)s] %(levelname)s | %(message)s'
- leaf_engine.logging.LOG_NAME = 'leaf_engine'
- leaf_engine.logging.logger