Async Logging for Python
Project description
alogging
alogging
is a Python library that provides asynchronous logging capabilities. It is designed to work with the standard Python logging
module, but adds asynchronous functionality to improve performance in applications that make heavy use of logging.
Features
- Asynchronous logging: Log messages are processed in a separate process to avoid blocking the main application.
- Compatibility: Works with the standard Python
logging
module, so you can use all the features and handlers you're familiar with. - Flexibility: Provides a variety of handlers, including
RotatingFileHandler
,HTTPHandler
,SMTPHandler
,SysLogHandler
, and more.
Usage
To use alogging
, you first need to start the backend process. This can be done using the start_backend
method:
import asyncio
import alogging
asyncio.run(alogging.start_backend())
You can then get a logger and use it just like you would with the standard logging
module:
log = alogging.getLogger("my_logger")
log.info("This is an info message")
You can also configure the logger using the basicConfig
function:
alogging.basicConfig(
filename="test.log",
level=alogging.DEBUG,
format="%(name)s - %(levelname)s - %(message)s",
)
Handlers
alogging
provides a variety of handlers that you can use to control where your log messages go. These include:
RotatingFileHandler
: Writes log messages to a file, with support for automatic rotation when the file reaches a certain size.HTTPHandler
: Sends log messages to a web server as HTTP POST requests.SMTPHandler
: Sends log messages to an email address using SMTP.SysLogHandler
: Sends log messages to a Unix syslog daemon.
To use a handler, you need to create an instance of it and add it to your logger:
handler = alogging.handlers.RotatingFileHandler("test.log", maxBytes=10000, backupCount=5)
log.addHandler(handler)
Installation
You can install alogging
using pip:
pip install py-extensions-alogging
Or add it using poetry:
poetry add py-extensions-alogging
Contributing
Contributions to alogging
are welcome. Please submit a pull request or create an issue on GitHub.
License
alogging
is licensed under the MIT License. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file py_extensions_alogging-0.1.1.tar.gz
.
File metadata
- Download URL: py_extensions_alogging-0.1.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.1 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e705a8aeeeba0177aa3eef2b8f45e762b3d9ad139085d088841762542e32c078 |
|
MD5 | 6cc8502425b86eb7423b4adf67f2eb60 |
|
BLAKE2b-256 | 7fe783c05429a60d54cc5f2034f317086034393197034f9b5ddffef7cbc7eb97 |
File details
Details for the file py_extensions_alogging-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: py_extensions_alogging-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.1 Darwin/23.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f3945e8dd2d9a70f206ac8ec22c0186891ec7d2a7aa7c637d8fccf081c7f877 |
|
MD5 | 780eec1e837e49b425973080ee239271 |
|
BLAKE2b-256 | 4692a39f03f224591c06f054f9de85d9e0528ce991f5fce88bb9d50e376eaa6c |