Skip to content

Commit 9d4e7c3

Browse files
committed
Provide a default value for server_name
This is a backwards-compatibility patch for modules that imported LoggingContext from within Synapse. See matrix-org/synapse-s3-storage-provider#133
1 parent 0615b64 commit 9d4e7c3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

synapse/logging/context.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@ class LoggingContext:
285285
Args:
286286
name: Name for the context for logging.
287287
server_name: The name of the server this context is associated with
288-
(`config.server.server_name` or `hs.hostname`)
288+
(`config.server.server_name` or `hs.hostname`).
289+
290+
If not provided, this will be set to "SERVER_NAME_NOT_PROVIDED".
291+
This is a backwards-compatibility patch for
292+
https://github.com/matrix-org/synapse-s3-storage-provider/issues/133.
289293
parent_context (LoggingContext|None): The parent of the new context
290294
request: Synapse Request Context object. Useful to associate all the logs
291295
happening to a given request.
@@ -309,7 +313,7 @@ def __init__(
309313
self,
310314
*,
311315
name: str,
312-
server_name: str,
316+
server_name: str = "SERVER_NAME_NOT_PROVIDED",
313317
parent_context: "Optional[LoggingContext]" = None,
314318
request: Optional[ContextRequest] = None,
315319
) -> None:

0 commit comments

Comments
 (0)