Skip to content

Support custom log attributes via extra logger parameter #253

Closed
@eoinsha

Description

@eoinsha

Hi!

I am using the aws-lambda-powertools-python logger for a number of projects but also have existing deployments using structured JSON logging implemented with a custom logger. Our custom logger supports the Python logging extra parameter to supply custom attributes. It would be great if the aws-lambda-powertools-python formatter supported custom attributes so we can take advantage of structured logging for additional attributes.

Example

from aws_lambda_powertools.logging import Logger
logger = Logger()
logger.info('Put aggregation result', extra={'key': 'results/sum.csv', 'size': 130425})

Current output:

{
  "level": "INFO",
  "location": "<module>:5",
  "message": "Put aggregation result",
  "timestamp": "2020-12-23 11:00:47,695",
  "service": "service_undefined",
  "sampling_rate": 0
}

Desired output:

{
  "level": "INFO",
  "location": "<module>:5",
  "message": "Put aggregation result",
  "timestamp": "2020-12-23 11:00:47,695",
  "service": "service_undefined",
  "sampling_rate": 0,
  "key": "results/sum.csv",
  "size": 130425
}

This enables us to do effective log queries, filtering and stats using CloudWatch Logs Insights.

For reference:

Is this something that you would consider supporting?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions