Logging into aws cloudwatch from python apps
Project description
# python setup.py sdist bdist_wheel
# twine upload dist/*
from awslogger import CloudWatchLogger
import logging
# Replace 'your_aws_key' and 'your_aws_secret' with actual values
# Create an instance of the CloudWatchLogger class
logger = CloudWatchLogger(ACCESS_KEY, SECRET_KEY, REGION_NAME)
logger.set_log_level(logging.ERROR) # Set logging level to INFO
log_group_name = 'my-log-group'
log_stream_name = 'my-log-stream'
logger.create_log_group(log_group_name)
logger.create_log_stream(log_group_name, log_stream_name)
function_name = 'Test function'
# # Log at different levels
logger.put_log_event(log_group_name, log_stream_name, "This is info message.", function_name, log_level=logging.INFO)
logger.put_log_event(log_group_name, log_stream_name, "This is debug message.", function_name, log_level=logging.DEBUG)
logger.put_log_event(log_group_name, log_stream_name, "This is warning message.", function_name, log_level=logging.WARNING)
logger.put_log_event(log_group_name, log_stream_name, "This is critical message.", function_name, log_level=logging.CRITICAL)
logger.put_log_event(log_group_name, log_stream_name, "This is error message.", function_name, log_level=logging.ERROR)
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
Close
Hashes for awscloudwatchlogger-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15bc461b964c7fcf4bae2c54f35e7118893b09d785303733ef3173c56598f026 |
|
MD5 | 7d7393873442246d63e87a4cbe8f8193 |
|
BLAKE2b-256 | 134acd5839dc2fb4eab4c1cee658d4350bc12a6dd94b7f89d3765a6e974c20a0 |