-
Notifications
You must be signed in to change notification settings - Fork 32
Add caller-provided logger configuration #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
637ad05
f99bf24
315e862
c191f6c
72a161c
9170e31
0942fc1
b0b9d3e
1aa1239
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,6 +268,72 @@ message formatting. | |
| > Create the replay-safe logger once at the start of your orchestrator | ||
| > and reuse it throughout the function. | ||
|
|
||
| ### SDK logging | ||
|
|
||
| `TaskHubGrpcClient`, `AsyncTaskHubGrpcClient`, and `TaskHubGrpcWorker` | ||
| accept a configured `logging.Logger` through their `logger` parameter. The | ||
| SDK uses a supplied logger unchanged: it does not add handlers or modify its | ||
| formatter, level, filters, or propagation setting. The Durable Task Scheduler | ||
| client and worker accept the same parameter. | ||
|
|
||
| Use one shared logger when client and worker records should use the same | ||
| destination, format, and correlation filters: | ||
|
|
||
| ```python | ||
| import logging | ||
|
|
||
| from durabletask.client import TaskHubGrpcClient | ||
| from durabletask.worker import TaskHubGrpcWorker | ||
|
|
||
| sdk_logger = logging.getLogger("myapp.durabletask") | ||
| sdk_logger.setLevel(logging.INFO) | ||
|
|
||
| handler = logging.StreamHandler() | ||
| handler.setFormatter(logging.Formatter( | ||
| "%(asctime)s %(name)s %(levelname)s %(message)s")) | ||
| sdk_logger.addHandler(handler) | ||
| sdk_logger.propagate = False | ||
|
|
||
| worker = TaskHubGrpcWorker(logger=sdk_logger) | ||
| client = TaskHubGrpcClient(logger=sdk_logger) | ||
| ``` | ||
|
|
||
| Because `logging.getLogger()` returns the same logger for a given name, | ||
| configure a shared logger once during application startup. Do not add a new | ||
| handler every time a client or worker is constructed, or every record will be | ||
| emitted once by each handler. | ||
|
|
||
| Alternatively, configure handlers on the root logger and allow propagation: | ||
|
|
||
| ```python | ||
| import logging | ||
|
|
||
| logging.basicConfig(level=logging.INFO) | ||
| sdk_logger = logging.getLogger("myapp.durabletask") | ||
|
|
||
| worker = TaskHubGrpcWorker(logger=sdk_logger) | ||
| client = TaskHubGrpcClient(logger=sdk_logger) | ||
| ``` | ||
|
|
||
| > [!WARNING] | ||
| > Use either handlers attached directly to `sdk_logger` with | ||
| > `sdk_logger.propagate = False`, or root handlers with propagation enabled. | ||
| > Combining both emits each Durable Task record twice. | ||
|
|
||
| Pass separate named loggers when clients and workers need independently | ||
| configured levels, destinations, or filters: | ||
|
|
||
| ```python | ||
| worker = TaskHubGrpcWorker( | ||
| logger=logging.getLogger("myapp.durabletask.worker")) | ||
| client = TaskHubGrpcClient( | ||
| logger=logging.getLogger("myapp.durabletask.client")) | ||
| ``` | ||
|
|
||
| The older `log_handler` and `log_formatter` parameters are deprecated. They | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The guide still contains a second ### Logging configuration section at lines 640-661 that recommends log_handler/log_formatter and demonstrates log_handler=.... That contradicts this new deprecation guidance. Please merge, update, or remove the old section so the feature guide no longer recommends deprecated options. |
||
| will be removed in a future major release. Passing either one together with | ||
| `logger` raises `ValueError`; none of the supplied logging options are ignored. | ||
|
|
||
| ### Large payload externalization | ||
|
|
||
| Orchestration inputs, outputs, and event data are transmitted through gRPC messages. When these | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This heading now puts the pre-existing continue_as_new(new_version=...) entry (lines 23-25) under CHANGED, although it was an ADDED entry on main. Please move CHANGED below that entry. While touching these entries, please also preserve the changelog's unindented continuation style; the new wrapped lines here and in both provider changelogs currently use two-space indentation.