1+ """
2+ Logger utility
3+ !!! abstract "Usage Documentation"
4+ [`Logger`](../../core/logger.md)
5+ """
16from __future__ import annotations
27
38import functools
@@ -82,7 +87,7 @@ class Logger:
8287 by default "INFO"
8388 child: bool, optional
8489 create a child Logger named <service>.<caller_file_name>, False by default
85- sample_rate : float, optional
90+ sampling_rate : float, optional
8691 sample rate for debug calls within execution context defaults to 0.0
8792 stream: sys.stdout, optional
8893 valid output for a logging stream, by default sys.stdout
@@ -103,7 +108,6 @@ class Logger:
103108 use_datetime_directive: bool, optional
104109 Interpret `datefmt` as a format string for `datetime.datetime.strftime`, rather than
105110 `time.strftime`.
106-
107111 See https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior . This
108112 also supports a custom %F directive for milliseconds.
109113 use_rfc3339: bool, optional
@@ -116,7 +120,6 @@ class Logger:
116120 by default json.loads
117121 json_default : Callable, optional
118122 function to coerce unserializable values, by default `str()`
119-
120123 Only used when no custom formatter is set
121124 utc : bool, optional
122125 set logging timestamp to UTC, by default False to continue to use local time as per stdlib
@@ -590,17 +593,19 @@ def append_context_keys(self, **additional_keys: Any) -> Generator[None, None, N
590593 """
591594 Context manager to temporarily add logging keys.
592595
593- Parameters:
596+ Parameters
594597 -----------
595- **keys : Any
598+ **additional_keys : Any
596599 Key-value pairs to include in the log context during the lifespan of the context manager.
597600
598- Example:
601+ Example
599602 --------
600- >>> logger = Logger(service="example_service")
601- >>> with logger.append_context_keys(user_id="123", operation="process"):
602- >>> logger.info("Log with context")
603- >>> logger.info("Log without context")
603+ **Logging with contextual keys**
604+
605+ logger = Logger(service="example_service")
606+ with logger.append_context_keys(user_id="123", operation="process"):
607+ logger.info("Log with context")
608+ logger.info("Log without context")
604609 """
605610 with self .registered_formatter .append_context_keys (** additional_keys ):
606611 yield
0 commit comments