Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Morgan
bce22241e8 re-use newsfile text from #18868 2025-10-01 15:20:23 +01:00
Andrew Morgan
9d4e7c331f Provide a default value for server_name
This is a backwards-compatibility patch for modules that imported LoggingContext from within Synapse. See
https://github.com/matrix-org/synapse-s3-storage-provider/issues/133
2025-10-01 15:17:56 +01:00
2 changed files with 7 additions and 2 deletions

1
changelog.d/19003.misc Normal file
View File

@@ -0,0 +1 @@
Fix `server_name` in logging context for multiple Synapse instances in one process.

View File

@@ -285,7 +285,11 @@ class LoggingContext:
Args:
name: Name for the context for logging.
server_name: The name of the server this context is associated with
(`config.server.server_name` or `hs.hostname`)
(`config.server.server_name` or `hs.hostname`).
If not provided, this will be set to "SERVER_NAME_NOT_PROVIDED".
This is a backwards-compatibility patch for
https://github.com/matrix-org/synapse-s3-storage-provider/issues/133.
parent_context (LoggingContext|None): The parent of the new context
request: Synapse Request Context object. Useful to associate all the logs
happening to a given request.
@@ -309,7 +313,7 @@ class LoggingContext:
self,
*,
name: str,
server_name: str,
server_name: str = "SERVER_NAME_NOT_PROVIDED",
parent_context: "Optional[LoggingContext]" = None,
request: Optional[ContextRequest] = None,
) -> None: