Skip to content

Commit cf11f56

Browse files
author
Artur Shiriev
committed
add setting to enable logging
1 parent c0e3b57 commit cf11f56

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

docs/introduction/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ For FastStream you must provide additionally:
8686

8787
## Structlog
8888

89-
To bootstrap Structlog, you must set `service_debug` to False
89+
To bootstrap Structlog, you must keep `logging_enabled` to True
9090

9191
Additional parameters:
9292

lite_bootstrap/instruments/logging_instrument.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def __call__(self, *args: typing.Any) -> logging.Logger: # noqa: ANN401
8383

8484
@dataclasses.dataclass(kw_only=True, frozen=True)
8585
class LoggingConfig(BaseConfig):
86+
logging_enabled: bool = True
8687
logging_log_level: int = logging.INFO
8788
logging_flush_level: int = logging.ERROR
8889
logging_buffer_capacity: int = 10
@@ -95,11 +96,11 @@ class LoggingConfig(BaseConfig):
9596
@dataclasses.dataclass(kw_only=True, slots=True, frozen=True)
9697
class LoggingInstrument(BaseInstrument):
9798
bootstrap_config: LoggingConfig
98-
not_ready_message = "service_debug is True"
99+
not_ready_message = "logging_enabled is False"
99100
missing_dependency_message = "structlog is not installed"
100101

101102
def is_ready(self) -> bool:
102-
return not self.bootstrap_config.service_debug and import_checker.is_structlog_installed
103+
return self.bootstrap_config.logging_enabled and import_checker.is_structlog_installed
103104

104105
@staticmethod
105106
def check_dependencies() -> bool:

tests/test_free_bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_free_bootstrap(free_bootstrapper_config: FreeBootstrapperConfig) -> Non
3434
def test_free_bootstrap_logging_not_ready(log_output: list[EventDict]) -> None:
3535
FreeBootstrapper(
3636
bootstrap_config=FreeBootstrapperConfig(
37-
service_debug=True,
37+
logging_enabled=False,
3838
opentelemetry_endpoint="otl",
3939
opentelemetry_instrumentors=[CustomInstrumentor()],
4040
opentelemetry_span_exporter=ConsoleSpanExporter(),
@@ -43,7 +43,7 @@ def test_free_bootstrap_logging_not_ready(log_output: list[EventDict]) -> None:
4343
),
4444
)
4545
assert log_output == [
46-
{"event": "LoggingInstrument is not ready, because service_debug is True", "log_level": "info"}
46+
{"event": "LoggingInstrument is not ready, because logging_enabled is False", "log_level": "info"}
4747
]
4848

4949

0 commit comments

Comments
 (0)