Skip to content

Commit

Permalink
Add FirehoseHandler (#2)
Browse files Browse the repository at this point in the history
* Add FirehoseHandler class definition

* Add boto3 dependencies

* Add FirehoseHandler and tests

* Remove debugging prints
  • Loading branch information
Kirade authored Dec 28, 2022
1 parent 68cd240 commit 5a35314
Show file tree
Hide file tree
Showing 6 changed files with 513 additions and 150 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,58 @@
[![codecov](https://codecov.io/gh/8percent/aws-firehose-handler/branch/master/graph/badge.svg?token=QKO8M4RLO6)](https://codecov.io/gh/8percent/aws-firehose-handler)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)


Python logging handler to load data into AWS Kinesis Delivery Stream

### Demo Script
```
CONFIG = {
'version': 1,
'root': {
'level': 'DEBUG',
'handlers': ['console'],
},
'formatters': {
'json': {
'class': 'pythonjsonlogger.jsonlogger.JsonFormatter',
'format': '%(asctime)s %(name)s %(levelname)s %(message)s %(pathname)s %(lineno)d %(funcName)s %(process)d %(processName)s %(thread)d %(threadName)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
},
'firehose': {
'level': 'INFO',
'formatter': 'json',
'class': 'firehose_handler.FirehoseHandler',
'profile_name': 'Insert AWS Credential Profile Name',
'region_name': 'Insert AWS Region Name',
'delivery_stream_name': 'Insert Delivery Stream Name',
},
},
'loggers': {
'test-logger': {
'handlers': ['firehose'],
'level': 'INFO',
'propagate': False,
},
},
}
logging.config.dictConfig(CONFIG)
logger = logging.getLogger('test-logger')
def test():
try:
raise NameError("fake NameError")
except NameError as e:
logger.error(e, exc_info=True)
if __name__ == '__main__':
test()
```
Loading

0 comments on commit 5a35314

Please sign in to comment.