A Python logging handler to sends logs to AWS SQS
Project description
logging_aws_sqs
Python module for sending events to AWS SQS
Installation
pip install logging_aws_sqs
Features
- Log message to AWS SQS (Simple Queue Service) directly.
- All messages are send as as is it by default. If no time is available in events, current timestamp is used.
Sample Code
import logging
from time import sleep
from logging_aws_sqs import AWSSQSHandler
logger = logging.getLogger('AWSSQSHandler')
logger.setLevel(logging.DEBUG)
queue = "testqueue"
aws_key_id = "XXXXXXXXXXXXXXXXXXX"
aws_secret_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
region = "us-east-1"
sqs_handler = AWSSQSHandler(queue, aws_key_id, aws_secret_key, region)
logger.addHandler(sqs_handler)
for i in range(1, 3):
dict_obj = {'message': {'eventnumber': i, 'api_endpoint': 'test_endpoint'},
'user': 'abhinav', 'app': 'my demo app', 'severity': 'low'}
logger.info(dict_obj)
logger.warning("This is sample warning messages")
logger.error("ERROR!! This is sample ERROR message")
logger.debug("DEBUG!!, Sample Debug Message")
sleep(5)
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
logging_aws_sqs-1.0.0.tar.gz
(2.8 kB
view details)
File details
Details for the file logging_aws_sqs-1.0.0.tar.gz
.
File metadata
- Download URL: logging_aws_sqs-1.0.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81251bd0c674be43feafb8c83b0056727a9e0f1cd281c2ba074cd9b5d9687a27 |
|
MD5 | a07b2218f385951f4471c921d9cb9e5f |
|
BLAKE2b-256 | 7d47fdb903e50539b23b0a5bb8b3de213a3d12ffe122327ad690558ce24741a0 |