Lambo
Simple and visually pleasing logger for AWS Lambda that prepends your log lines with the log level and the AWS request ID, making searching CLoudWatch for event logs a cinch!
Before installing lambo…
START RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 Version: $LATEST
This log line was generated with ``print()``
END RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149
REPORT RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 Duration: 3000.00 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 128 MB
After installing lambo…
START RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 Version: $LATEST
DEBUG RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 This log line was generated with ``logger.debug()``
INFO RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 This log line was generated with ``logger.info()``
WARNING RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 This log line was generated with ``logger.warning()``
ERROR RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 This log line was generated with ``logger.error()``
END RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149
REPORT RequestId: 03cf3256-f2e1-461c-a4a0-60eb91ac8149 Duration: 3000.00 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 128 MB
Why not use aws_lambda_powertools? If you are already building your Lambda package with external dependencies well then you could probably use that great tool by AWS.
But if you are looking for a lighter-weight solution with no external dependencies, then this might help you.
Installation
pip install lambo
Usage
Create a logger using the getLogger() method and bind it to your Lambda handler functions with the @bind decorator.
import lambo
logger = lambo.getLogger('my-logger')
@logger.bind
def handler(event, context):
logger.info('HELLO!')
return {'ok': True}
Or, if brevity is your thing, import the built-in logger:
from lambo import logger
@logger.bind
def handler(event, context):
logger.info('HELLO!')
return {'ok': True}
Customization
The default log level for lambo loggers is INFO and the default format string is %(levelname)s %(awsRequestId)s %(message)s, where awsRequestId is extracted from the Lambda execution context.
You can override these values at runtime…
import lambo
logger = lambo.getLogger('my-logger', 'DEBUG', '%(message)s')
Or with ENV variables…
export LAMBO_LOG_LEVEL=DEBUG
export LAMBO_LOG_FORMAT="%(message)"
Metadata
Release files for lambo 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lambo-0.4.0.tar.gz | 6.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lambo-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / lambo-0.4.0.tar.gz
| Download URL | lambo-0.4.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7ff3bc9ad7c00fad701b90b0502247157c92ab1146d1933418817ec3700e312
|
|
BLAKE2b-256 checksum How to use checksums |
719e3b7e8f3aff79be3d450bd1a35f439f4c99c4705863bed3068e3e0b6bbb43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / lambo-0.4.0-py3-none-any.whl
| Download URL | lambo-0.4.0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26bc71682f3b3e4b1ca60bab784894ea33682f456c2498869b8022cd3fd1e5f3
|
|
BLAKE2b-256 checksum How to use checksums |
ce1cd0b894ebf0462c53211ae5f41ed0ac400ec8087f97bcafc5cafd9d30e3ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|