An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

[![PyPI - Version](https://img.shields.io/pypi/v/loggext)
](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
```