Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 1ee268d

Browse files
authored
Improve the backwards compatibility re-exports of synapse.logging.context (#5617)
* Improve the backwards compatibility re-exports of synapse.logging.context. * reexport logformatter too
1 parent ee91ac1 commit 1ee268d

File tree

4 files changed

+62
-5
lines changed

4 files changed

+62
-5
lines changed

changelog.d/5617.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Move logging code out of `synapse.util` and into `synapse.logging`.

synapse/util/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@
2121

2222
from twisted.internet import defer, task
2323

24-
from synapse.logging import context, formatter
24+
from synapse.logging import context
2525

2626
logger = logging.getLogger(__name__)
2727

28-
# Compatibility alias, for existing logconfigs.
29-
logcontext = context
30-
logformatter = formatter
31-
3228

3329
def unwrapFirstError(failure):
3430
# defer.gatherResults and DeferredLists wrap failures.

synapse/util/logcontext.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2019 The Matrix.org Foundation C.I.C.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Backwards compatibility re-exports of ``synapse.logging.context`` functionality.
17+
"""
18+
19+
from synapse.logging.context import (
20+
LoggingContext,
21+
LoggingContextFilter,
22+
PreserveLoggingContext,
23+
defer_to_thread,
24+
make_deferred_yieldable,
25+
nested_logging_context,
26+
preserve_fn,
27+
run_in_background,
28+
)
29+
30+
__all__ = [
31+
"defer_to_thread",
32+
"LoggingContext",
33+
"LoggingContextFilter",
34+
"make_deferred_yieldable",
35+
"nested_logging_context",
36+
"preserve_fn",
37+
"PreserveLoggingContext",
38+
"run_in_background",
39+
]

synapse/util/logformatter.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2019 The Matrix.org Foundation C.I.C.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
Backwards compatibility re-exports of ``synapse.logging.formatter`` functionality.
17+
"""
18+
19+
from synapse.logging.formatter import LogFormatter
20+
21+
__all__ = ["LogFormatter"]

0 commit comments

Comments
 (0)