An example package
Project description
pdlogger
pdlogger is a python based logger that let's you push your logging.info() calls to an AMQP queue.
Installation
pdlogger is available on pypi. Just do:
pip install pdlogger
Usage
Client application
Once you have installed pdlogger, setup the logger in the initial steps of your application by doing:
import logging
from pdlogger.Logging import AMQPLoggingHandler
from pdlogger.Logging import AMQPLogger
from pdlogger.Logging import EnvVarChecker
logging.setLoggerClass(AMQPLogger)
logger = logging.getLogger("pdlogs")
logger.setLevel(logging.INFO)
handler = AMQPLoggingHandler()
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
Then, in all other modules of your application, just do
import logging
logger = logging.getLogger('pdlogs')
logger.info(<your data here>)
You can either set AMQP_URL, QUEUE_NAME in the environment variables, or they can be passed to the AMQPLoggingHandler like:
AMQPLoggingHandler(amqp_url, queue_name, msg_priority)
logger.info takes the following arguments:
- msg: Logs that you want to push. Anything that is JSON serializable goes.
- project_id (Optional): Project ID. Can be left None. E.g. hf38fgf883fg3bs3
- test_image_id (Optional): Test Image ID. Can be left None. E.g. 73184492
- application_name (Optional): Application Name. Can be left None. E.g. all-in-1
- checkpoint_name: Arbitrary string to keep track of where the log is coming from. E.g. opensetThreshApplied, otherRemoved.
Producer
You need atleast 1 consumer running to consume the logs. To run a consumer application, just run:
from pdlogger.Logging import AMQPConsumer
consumer = AMQPConsumer()
consumer.start_consuming()
You can either set AMQP_URL, QUEUE_NAME, SQL_HOST, SQL_USER, SQL_PASSWORD, SQL_DATABASE in the environment variables, or they can be passed to the AMQPConsumer like:
AMQPConsumer(amqp_url, queue_name, sql_host, sql_user, sql_password, sql_database)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdlogger-0.0.3.tar.gz.
File metadata
- Download URL: pdlogger-0.0.3.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d58a74a152468d7377e4d53a2fd85c7204a76bff8f65b442f25a587a61087cb
|
|
| MD5 |
d2f63d411c9821da830d080e1a22f1e9
|
|
| BLAKE2b-256 |
00124bbbfa74cd327b56de2bdaaa76bc3df29a8bcceda800e215a2687c5adb72
|
File details
Details for the file pdlogger-0.0.3-py3-none-any.whl.
File metadata
- Download URL: pdlogger-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50518c3629d676e01bbc2f602b0a154f1253745f459a54917d15b01fed5a8661
|
|
| MD5 |
0e931795a3d88bebd7b10a17109cf8ae
|
|
| BLAKE2b-256 |
5fade0ec1045f30e51b199fd2d63492bb3ebc76a18c0dd6a3431627b8895f477
|