Skip to main content

Nanolib to enhance logging in aws lambda

Project description

==================
AWS Lambda Logging
==================

.. image:: https://gitlab.com/hadrien/aws_lambda_logging/badges/master/build.svg

.. image:: https://gitlab.com/hadrien/aws_lambda_logging/badges/master/coverage.svg?job=Run%20py.test

Better logging for aws lambda running on python runtime environment with a
highly opinionated JSON formatting to ease parsing on any logging system.

Usage
=====

.. code::

import aws_lambda_logging


def handler(event, context):
aws_lambda_logging.setup(level='DEBUG')
...

You can separately set the logging level for Boto (defaults to the same level):

.. code::

import aws_lambda_logging


def handler(event, context):
aws_lambda_logging.setup(level='DEBUG', boto_level='CRITICAL')
...



You can add keyword arguments to be logged each time, such as lambda request
id.

.. code::

import aws_lambda_logging


def handler(event, context):
aws_lambda_logging.setup(level='DEBUG',
aws_request_id=context.get('aws_request_id'))
log.debug('Just a try!')
...


It will output JSON formatted message:

.. code::

{
"level": "DEBUG",
"timestamp": "2016-10-03 13:27:57,438",
"apigw_request_id": "323fee86-896d-11e6-b7fd-2d914ea80962",
"location": "root.handler:6",
"message": "Just a try!"
}

You can input a JSON string:
.. code::
...
log.debug("{"Details": [1,2,3]}")
...

It will output JSON formatted message with the JSON string embedded properly:

.. code::

{
"level": "DEBUG",
"timestamp": "2016-10-03 13:27:57,438",
"apigw_request_id": "323fee86-896d-11e6-b7fd-2d914ea80962",
"location": "root.handler:6",
"message": {
"Details": [
1,
2,
3
]
}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_lambda_logging-0.0.20.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file aws_lambda_logging-0.0.20.tar.gz.

File metadata

File hashes

Hashes for aws_lambda_logging-0.0.20.tar.gz
Algorithm Hash digest
SHA256 54cae1d259465c4961282ec506d0e56ca3fc14a2bffd1dd03295b5c9c931e024
MD5 111fbd8e053d066290dc75b54c94a348
BLAKE2b-256 3caa606f2f210f4f16af874b8faedf73d2a2195cb93d607b4b4d744c26c6f866

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page