Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 920 Bytes

README.md

File metadata and controls

38 lines (28 loc) · 920 Bytes

CWLogger

Simple handler for cloudwatch logging. Just found it helpful rather than re-writing a handler each time I need to create a log, since the boto3 logs client isn't the easiest thing to work with.

Usage

Requires boto3 to be installed and configured with read-write permissions to cloudwatch-logs.

If the log group is setup ahead of runtime, create-group permission is not needed.

import mylogger

log = mylogger.CWLog()
log.log("Text to log to cloudwatch-logs")

A specific log group can be specified:

log = mylogger.CWLog(logGroup='MyTestLogGroup/mylogs')

A specific log stream prefix can be specified:

log = mylogger.CWLog(logStreamName='MyStreamPrefix')

Creating a log in a different AWS region can be done:

log = mylogger.CWLog(region='ap-east-1')

The default values:

defaultLogGroup = 'MyCustomLogs/Logs'
defaultLogStream = 'LogStream'
region = 'us-east-1'