leaf_engine.logging =================== .. py:module:: leaf_engine.logging Attributes ---------- .. autoapisummary:: leaf_engine.logging.DATE_FORMAT leaf_engine.logging.LOG_FORMAT leaf_engine.logging.LOG_NAME leaf_engine.logging.logger Functions --------- .. autoapisummary:: leaf_engine.logging._get_file_handler leaf_engine.logging._get_log_path leaf_engine.logging._get_stream_handler leaf_engine.logging.get_logger leaf_engine.logging.log leaf_engine.logging.log_git leaf_engine.logging.log_params leaf_engine.logging.log_shape leaf_engine.logging.log_spend leaf_engine.logging.setup_logger Module Contents --------------- .. py:function:: _get_file_handler(file_name: str, level=logging.INFO, mode='a') .. py:function:: _get_log_path() .. py:function:: _get_stream_handler(level=logging.INFO) .. py:function:: get_logger() .. py:function:: 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 .. py:function:: log_git() -> None .. py:function:: log_params(input_params: dict) -> None .. py:function:: log_shape(*factory_args, **factory_kwargs) Decorator factory that allows adding arguments to the log_shape explicit decorator below. .. py:function:: log_spend(*factory_args, **factory_kwargs) Decorator factory that allows adding arguments to the log_shape explicit decorator below. .. py:function:: setup_logger(file_name: str, cloudwatch: bool = True) Sets up local file and AWS CloudWatch log handlers. :param cloudwatch: Enables writing logs to AWS CloudWatch in the :type cloudwatch: bool, optional :param leaf_engine log group. Defaults to True.: .. py:data:: DATE_FORMAT :value: '%Y-%m-%d %H:%M:%S%z' .. py:data:: LOG_FORMAT :value: '[%(asctime)s] %(levelname)s | %(message)s' .. py:data:: LOG_NAME :value: 'leaf_engine' .. py:data:: logger