8000 change std logging config · modern-python/lite-bootstrap@863d160 · GitHub
[go: up one dir, main page]

Skip to content

Commit 863d160

Browse files
committed
change std logging config
1 parent 14b261e commit 863d160

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lite_bootstrap/instruments/logging_instrument.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ def check_dependencies() -> bool:
108108
def bootstrap(self) -> None:
109109
# Configure basic logging to allow structlog to catch its events
110110
logging.basicConfig(
111-
format="%(message)s",
111+
format="%(levelname)s [%(asctime)s] %(module)s %(pathname)s - %(message)s",
112112
stream=sys.stdout,
113-
level=logging.INFO,
113+
datefmt="%Y-%m-%d %H:%M:%S",
114+
level=self.bootstrap_config.logging_log_level,
114115
)
115116

116117
for unset_handlers_logger in self.bootstrap_config.logging_unset_handlers:

tests/instruments/test_logging_instrument.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@
1010

1111

1212
logger = structlog.getLogger(__name__)
13+
std_logger = logging.getLogger(__name__)
1314

1415

15-
def test_logging_instrument() -> None:
16+
def test_logging_instrument_simple() -> None:
1617
logging_instrument = LoggingInstrument(
17-
bootstrap_config=LoggingConfig(logging_unset_handlers=["uvicorn"], logging_buffer_capacity=0)
18+
bootstrap_config=LoggingConfig(
19+
logging_unset_handlers=["uvicorn"], logging_buffer_capacity=0, service_debug=False
20+
)
1821
)
1922
try:
2023
logging_instrument.bootstrap()
21-
logger.info("testing logging", key="value")
24+
logger.info("testing structlog", key="value")
25+
std_logger.info("testing std logger", extra={"key": "value"})
2226
finally:
2327
logging_instrument.teardown()
2428

0 commit comments

Comments
 (0)
0