Metadata-Version: 2.4
Name: ruth-logger
Version: 2022.0.0
Summary: Python configuration package
Author-email: Eyes Rutherford <ruth-tools@inbox.ru>
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: ruth-tokenizer>=2022.0.0
Requires-Dist: ruth-configurator>=2022.0.0
Requires-Dist: ruth-tools[common]>=2022.0.0
Dynamic: license-file

# Logging

This module injects into method a logger object and try to inspect and log input parameters and method result and/or error in a pretty way as a hierarchical tree of calls.
Can be used both for sync and async methods.


Examples:

- [ ] configuration:
    ```python
    from logger import Logger, LogTypes, Console, File, LogContext, logging
  
    logger = Logger(
        type=[
            LogTypes.debug,
            LogTypes.info,
            LogTypes.warning,
            LogTypes.error
        ],
        outputs=(
            Console(
                enabled=True
            ),
            File(
                enabled=True,
                path='./logs',
                name='log.ext'
            )
        )
    )
  
    # as global logger ----
    from tools.configurator import Config, ConfigNode
    # config load
    Config.globals = ConfigNode()
    Config.globals.logger = logger
    
    # as logging context ----
    from tools.logging import LogContext
    log_ctx_token = LogContext.set(logger=logger)
    # some code
    # at the end
    LogContext.reset(token=log_ctx_token)    
    ```
  
    use for logs:
    ```python
    from logging import logging
    
    @logging(prefix=__name__)
    def some_method():
        some_method.logger.debug(
            obj='some debug info',
            prefix='!!! > ',  # object prefix if needed
            date_: True,  # add date before log message
            indent: True,  # all logs from begin of start row or as hierarchy tree
            end_line: 1  # 0 - no end of line
        )
        # method logic here
        pass 
    ```
  
