You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
5
5
This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format for changes and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
7
+
## 1.25.3 - 2022-03-09
8
+
9
+
### Bug Fixes
10
+
11
+
***logger:** ensure state is cleared for custom formatters ([#1072](https://github.com/awslabs/aws-lambda-powertools-python/issues/1072))
12
+
13
+
### Documentation
14
+
15
+
***plugin:** add mermaid to create diagram as code ([#1070](https://github.com/awslabs/aws-lambda-powertools-python/issues/1070))
By default, Logger uses [LambdaPowertoolsFormatter](#lambdapowertoolsformatter) that persists its custom structure between non-cold start invocations. There could be scenarios where the existing feature set isn't sufficient to your formatting needs.
864
864
865
-
For **minor changes like remapping keys** after all log record processing has completed, you can override `serialize` method from [LambdaPowertoolsFormatter](#lambdapowertoolsformatter):
865
+
???+ info
866
+
The most common use cases are remapping keys by bringing your existing schema, and redacting sensitive information you know upfront.
867
+
868
+
For these, you can override the `serialize` method from [LambdaPowertoolsFormatter](#lambdapowertoolsformatter).
866
869
867
870
=== "custom_formatter.py"
868
871
@@ -892,28 +895,39 @@ For **minor changes like remapping keys** after all log record processing has co
892
895
}
893
896
```
894
897
895
-
For **replacing the formatter entirely**, you can subclass `BasePowertoolsFormatter`, implement `append_keys` method, and override `format` standard logging method. This ensures the current feature set of Logger like [injecting Lambda context](#capturing-lambda-context-info) and [sampling](#sampling-debug-logs) will continue to work.
898
+
The `log` argument is the final log record containing [our standard keys](#standard-structured-keys), optionally [Lambda context keys](#capturing-lambda-context-info), and any custom key you might have added via [append_keys](#append_keys-method) or the [extra parameter](#extra-parameter).
899
+
900
+
For exceptional cases where you want to completely replace our formatter logic, you can subclass `BasePowertoolsFormatter`.
901
+
902
+
???+ warning
903
+
You will need to implement `append_keys`, `clear_state`, override `format`, and optionally `remove_keys` to keep the same feature set Powertools Logger provides. This also means keeping state of logging keys added.
896
904
897
-
???+ info
898
-
You might need to implement `remove_keys` method if you make use of the feature too.
899
905
900
906
=== "collect.py"
901
907
902
-
```python hl_lines="2 4 7 12 16 27"
908
+
```python hl_lines="5 7 9-10 13 17 21 24 35"
909
+
import logging
910
+
from typing import Iterable, List, Optional
911
+
903
912
from aws_lambda_powertools import Logger
904
913
from aws_lambda_powertools.logging.formatter import BasePowertoolsFormatter
905
914
906
915
class CustomFormatter(BasePowertoolsFormatter):
907
-
custom_format = {} # arbitrary dict to hold our structured keys
Copy file name to clipboardExpand all lines: pyproject.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
[tool.poetry]
2
2
name = "aws_lambda_powertools"
3
-
version = "1.25.2"
3
+
version = "1.25.3"
4
4
description = "A suite of utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, batching, idempotency, feature flags, and more."
5
5
authors = ["Amazon Web Services"]
6
6
include = ["aws_lambda_powertools/py.typed", "THIRD-PARTY-LICENSES"]
0 commit comments