https://github.com/utility-libraries/loggext-py
logging extensions for pythons logging library
https://github.com/utility-libraries/loggext-py
logging python3 python3-logging
Last synced: 3 months ago
JSON representation
logging extensions for pythons logging library
- Host: GitHub
- URL: https://github.com/utility-libraries/loggext-py
- Owner: utility-libraries
- License: gpl-3.0
- Created: 2024-07-27T10:18:50.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-01T17:12:27.000Z (over 1 year ago)
- Last Synced: 2024-12-31T10:43:38.811Z (over 1 year ago)
- Topics: logging, python3, python3-logging
- Language: Python
- Homepage: https://utility-libraries.github.io/loggext-py/
- Size: 717 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[
](https://pypi.org/project/loggext/)
# loggext-py
logging extensions for pythons logging library
See the [Documentation](https://utility-libraries.github.io/loggext-py/).
* [loggext-py](#loggext-py)
* [Installation](#installation)
* [Features](#features)
* [Usage](#usage)
## Installation
```shell
pip install loggext
```
## Features
- function-decorators for logging
- with support for asnyc-functions
- additional logging-handlers
- ColoredConsoleHandler
## Usage
```python
import logging
import loggext
from loggext.decorators import add_logging
# only configures if not already configured
if not loggext.logging_is_configured():
logging.basicConfig(
level=logging.NOTSET,
handlers=[
# adds colored output based on the level of each message
loggext.handlers.ColoredConsoleHandler()
],
)
@add_logging(
call=True, # logs when the function is called
call_args=True, # logs passed arguments of call
timeit=True, # measure performance of the function
timeit_precision=2, # number of units when formatting timing
result=True, # log the result
) # note: exception-logging is always
def myfn(arg):
... # your code
myfn("value")
# DEBUG:root: was called with ('value')
# DEBUG:root: returned None after 65μs+614ns
```