File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -406,3 +406,29 @@ def test_lambda_handler(lambda_handler, lambda_context):
406
406
test_event = {' test' : ' event' }
407
407
lambda_handler(test_event, lambda_context) # this will now have a Context object populated
408
408
```
409
+
410
+ ## FAQ
411
+
412
+ ** How can I enable boto3 and botocore library logging?**
413
+
414
+ You can enable the ` botocore ` and ` boto3 ` logs by using the ` set_stream_logger ` method, this method will add a stream handler
415
+ for the given name and level to the logging module. By default, this logs all boto3 messages to stdout.
416
+
417
+ ``` python:title=log_botocore_and_boto3.py
418
+ from typing import Dict, List
419
+ from aws_lambda_powertools.utilities.typing import LambdaContext
420
+ from aws_lambda_powertools import Logger
421
+
422
+ import boto3
423
+ boto3.set_stream_logger() # highlight-line
424
+ boto3.set_stream_logger(' botocore' ) # highlight-line
425
+
426
+ logger = Logger()
427
+ client = boto3.client(' s3' )
428
+
429
+
430
+ def handler (event : Dict, context : LambdaContext) -> List:
431
+ response = client.list_buckets()
432
+
433
+ return response.get(" Buckets" , [])
434
+ ```
You can’t perform that action at this time.
0 commit comments