Skip to content

Commit 5447dc4

Browse files
authored
feat(logger): allow handler with custom kwargs signature (#913)
1 parent 39b3136 commit 5447dc4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Diff for: aws_lambda_powertools/logging/logger.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def handler(event, context):
328328
)
329329

330330
@functools.wraps(lambda_handler)
331-
def decorate(event, context):
331+
def decorate(event, context, **kwargs):
332332
lambda_context = build_lambda_context_model(context)
333333
cold_start = _is_cold_start()
334334

Diff for: tests/functional/test_logger.py

+13
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,16 @@ def handler(event, context):
597597
first_log, second_log = capture_multiple_logging_statements_output(stdout)
598598
assert "my_key" in first_log
599599
assert "my_key" not in second_log
600+
601+
602+
def test_inject_lambda_context_allows_handler_with_kwargs(lambda_context, stdout, service_name):
603+
# GIVEN
604+
logger = Logger(service=service_name, stream=stdout)
605+
606+
# WHEN
607+
@logger.inject_lambda_context(clear_state=True)
608+
def handler(event, context, my_custom_option=None):
609+
pass
610+
611+
# THEN
612+
handler({}, lambda_context, my_custom_option="blah")

0 commit comments

Comments
 (0)