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

Commit

Permalink
Remove duplicate timestamp from test logs (_trial_temp/test.log) (#…
Browse files Browse the repository at this point in the history
…15636)

Fix #15618

### Before

```
2023-05-17 22:51:36-0500 [-] 2023-05-17 22:51:36,889 - synapse.server - 338 - INFO - sentinel - Finished setting up.
```

### After

```
2023-05-19 18:16:20-0500 [-] synapse.server - 338 - INFO - sentinel - Finished setting up.
```


### Dev notes

The `Twisted.Logger` controls the `2023-05-19 18:16:20-0500 [-]` prefix, see : [`twisted/twisted` -> `src/twisted/logger/_format.py#L362-L374`](https://github.com/twisted/twisted/blob/34b161e66bc7c9f9efbb95e82c770a863933e498/src/twisted/logger/_format.py#L362-L374)

And we delegate our logs to the Twisted Logger for the tests which puts it in `_trial_temp/test.log`
  • Loading branch information
MadLittleMods authored May 22, 2023
1 parent 737f7dd commit 1903c7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/15636.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove duplicate timestamp from test logs (`_trial_temp/test.log`).
7 changes: 3 additions & 4 deletions tests/test_utils/logging_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ def setup_logging() -> None:
"""
root_logger = logging.getLogger()

log_format = (
"%(asctime)s - %(name)s - %(lineno)d - "
"%(levelname)s - %(request)s - %(message)s"
)
# We exclude `%(asctime)s` from this format because the Twisted logger adds its own
# timestamp
log_format = "%(name)s - %(lineno)d - " "%(levelname)s - %(request)s - %(message)s"

handler = ToTwistedHandler()
formatter = logging.Formatter(log_format)
Expand Down

0 comments on commit 1903c7e

Please sign in to comment.