V0.1.0
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
|
||||
# eh-logger
|
||||
|
||||
> Simple helper to get easier formatted logger from the python logging module
|
||||
|
||||
# usage
|
||||
|
||||
import eh-logging, create a formatted logger and use the logger
|
||||
|
||||
```python
|
||||
# import
|
||||
import eh_logging as logging
|
||||
|
||||
# create formatted logger
|
||||
formatted_logger = logging.get_formatted_logger(
|
||||
'formatted_logger',
|
||||
console=True,
|
||||
console_level=logging.DEBUG,
|
||||
file=True,
|
||||
file_path=r'log\formatted_logger.log',
|
||||
file_level=logging.DEBUG,
|
||||
file_backup_count=5,
|
||||
file_rotate='h',
|
||||
)
|
||||
|
||||
# use the logger
|
||||
formatted_logger.debug('Example formatted DEBUG Message')
|
||||
formatted_logger.info('Example formatted INFO Message')
|
||||
formatted_logger.warning('Example formatted WARNING Message')
|
||||
formatted_logger.error('Example formatted ERROR Message')
|
||||
formatted_logger.critical('Example formatted CRITICAL Message')
|
||||
|
||||
```
|
||||
|
||||
use the decorator with the INFO level
|
||||
|
||||
```python
|
||||
# import
|
||||
import eh_logging as logging
|
||||
|
||||
# set default logger to DEBUG level to see output
|
||||
logging.set_default_level(logging.DEBUG)
|
||||
|
||||
|
||||
# use logging decorator with default logger
|
||||
@logging.Decorator.info(arg=True, kwarg=True, return_value=True, decimal_places=1)
|
||||
def example_function(first_param, second_param, *args, **kwargs):
|
||||
return first_param, second_param, *args, *kwargs
|
||||
|
||||
|
||||
# execute function
|
||||
example_function('Hello', 'world', 'test', 'example', hello='world', world='test')
|
||||
|
||||
```
|
||||
|
||||
use the decorator with own logger
|
||||
|
||||
```python
|
||||
# import
|
||||
import eh_logging as logging
|
||||
|
||||
|
||||
# create formatted logger
|
||||
formatted_logger = logging.get_formatted_logger(
|
||||
'example_decorator_logger',
|
||||
console=True,
|
||||
console_level=logging.DEBUG,
|
||||
file=True,
|
||||
file_path=r'log\decorator_logger.log',
|
||||
file_level=logging.DEBUG,
|
||||
file_backup_count=5,
|
||||
file_rotate='h',
|
||||
)
|
||||
|
||||
|
||||
# use logging decorator with custom logger
|
||||
@logging.Decorator.debug(logger=formatted_logger, arg=True, kwarg=True, return_value=True, decimal_places=1)
|
||||
def example_function(first_param, second_param, *args, **kwargs):
|
||||
return first_param, second_param, *args, *kwargs
|
||||
|
||||
|
||||
# execute function
|
||||
example_function('Hello', 'world', 'test', 'example', hello='world', world='test')
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user