Skip to content

Commit 2d8eb39

Browse files
Adding documentation
1 parent 452cf91 commit 2d8eb39

File tree

3 files changed

+9
-41
lines changed

3 files changed

+9
-41
lines changed

aws_lambda_powertools/logging/buffer/config.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def _validate_inputs(
4343
max_size: int,
4444
minimum_log_level: str,
4545
flush_on_error: bool,
46-
compress: bool,
4746
) -> None:
4847
"""
4948
Validate configuration inputs.
@@ -65,9 +64,6 @@ def _validate_inputs(
6564
if not isinstance(flush_on_error, bool):
6665
raise ValueError("flush_on_error must be a boolean")
6766

68-
if not isinstance(compress, bool):
69-
raise ValueError("compress must be a boolean")
70-
7167
@property
7268
def max_size(self) -> int:
7369
"""Maximum buffer size in bytes."""
@@ -82,8 +78,3 @@ def minimum_log_level(self) -> str:
8278
def flush_on_error(self) -> bool:
8379
"""Flag to flush buffer on error."""
8480
return self._flush_on_error
85-
86-
@property
87-
def compress(self) -> bool:
88-
"""Flag to compress buffered logs."""
89-
return self._compress

docs/core/logger.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -562,88 +562,78 @@ Use the `@logger.inject_lambda_context` decorator to automatically flush buffere
562562

563563
##### Flushing manually
564564

565+
<center>
565566
```mermaid
566567
sequenceDiagram
567568
participant Client
568569
participant Lambda
569570
participant Logger
570571
participant CloudWatch
571-
572572
Client->>Lambda: Invoke Lambda
573573
Lambda->>Logger: Initialize with DEBUG level buffering
574574
Logger-->>Lambda: Logger buffer ready
575-
576575
Lambda->>Logger: logger.debug("First debug log")
577576
Logger-->>Logger: Buffer first debug log
578-
579577
Lambda->>Logger: logger.info("Info log")
580578
Logger->>CloudWatch: Directly log info message
581-
582579
Lambda->>Logger: logger.debug("Second debug log")
583580
Logger-->>Logger: Buffer second debug log
584-
585581
Lambda->>Logger: logger.flush_buffer()
586582
Logger->>CloudWatch: Flush buffered debug logs to CloudWatch
587-
588583
Lambda->>Client: Return execution result
589-
590584
```
585+
<i>Flushing buffer manually</i>
586+
</center>
591587

592588
##### Flushing on error
593589

590+
<center>
594591
```mermaid
595592
sequenceDiagram
596593
participant Client
597594
participant Lambda
598595
participant Logger
599596
participant CloudWatch
600-
601597
Client->>Lambda: Invoke Lambda
602598
Lambda->>Logger: Initialize with DEBUG level buffering
603599
Logger-->>Lambda: Logger buffer ready
604-
605600
Lambda->>Logger: logger.debug("First log")
606601
Logger-->>Logger: Buffer first debug log
607-
608602
Lambda->>Logger: logger.debug("Second log")
609603
Logger-->>Logger: Buffer second debug log
610-
611604
Lambda->>Logger: logger.debug("Third log")
612605
Logger-->>Logger: Buffer third debug log
613-
614606
Lambda->>Lambda: Exception occurs
615607
Lambda->>Logger: logger.error("Error details")
616608
Logger->>CloudWatch: Send buffered debug logs
617609
Logger->>CloudWatch: Send error log
618-
619610
Lambda->>Client: Raise exception
620611
```
612+
<i>Flushing buffer when an error happens</i>
613+
</center>
621614

622615
##### Flushing when uncaught exception happens
623616

617+
<center>
624618
```mermaid
625619
sequenceDiagram
626620
participant Client
627621
participant Lambda
628622
participant Logger
629623
participant CloudWatch
630-
631624
Client->>Lambda: Invoke Lambda
632625
Lambda->>Logger: Using decorator @logger.inject_lambda_context(flush_buffer_on_uncaught_error=True)
633626
Logger-->>Lambda: Logger context injected
634-
635627
Lambda->>Logger: logger.debug("First log")
636628
Logger-->>Logger: Buffer first debug log
637-
638629
Lambda->>Logger: logger.debug("Second log")
639630
Logger-->>Logger: Buffer second debug log
640-
641631
Lambda->>Lambda: Uncaught Exception
642632
Lambda->>CloudWatch: Automatically send buffered debug logs
643-
644633
Lambda->>Client: Raise uncaught exception
645-
646634
```
635+
<i>Flushing buffer when an uncaught exception happens</i>
636+
</center>
647637

648638
#### Common buffering questions
649639

tests/unit/logger/required_dependencies/test_logger_buffer_config.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def test_default_configuration():
1111
assert config_buffer.max_size == 20480
1212
assert config_buffer.minimum_log_level == "DEBUG"
1313
assert config_buffer.flush_on_error is True
14-
assert config_buffer.compress is False
1514

1615

1716
def test_custom_configuration():
@@ -20,14 +19,12 @@ def test_custom_configuration():
2019
max_size=51200,
2120
minimum_log_level="WARNING",
2221
flush_on_error=False,
23-
compress=True,
2422
)
2523

2624
# THEN configuration is set with provided values
2725
assert config_buffer.max_size == 51200
2826
assert config_buffer.minimum_log_level == "WARNING"
2927
assert config_buffer.flush_on_error is False
30-
assert config_buffer.compress is True
3128

3229

3330
def test_invalid_max_size_negative():
@@ -79,13 +76,3 @@ def test_invalid_flush_on_error():
7976
with pytest.raises(ValueError, match="flush_on_error must be a boolean"):
8077
# THEN a ValueError is raised
8178
LoggerBufferConfig(flush_on_error=invalid_flush_on_error)
82-
83-
84-
def test_invalid_compress():
85-
# GIVEN an invalid compress type
86-
invalid_compress = "False"
87-
88-
# WHEN creating a LoggerBufferConfig / THEN
89-
with pytest.raises(ValueError, match="compress must be a boolean"):
90-
# THEN a ValueError is raised
91-
LoggerBufferConfig(compress=invalid_compress)

0 commit comments

Comments
 (0)