Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
929ae19d
Commit
929ae19d
authored
9 years ago
by
Paul Evans
Browse files
Options
Downloads
Plain Diff
Merge pull request #280 from matrix-org/paul/sighup
Hacky attempt at catching SIGHUP and rotating the logfile around
parents
728d07c8
9cd5b9a8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/config/logger.py
+14
-0
14 additions, 0 deletions
synapse/config/logger.py
with
14 additions
and
0 deletions
synapse/config/logger.py
+
14
−
0
View file @
929ae19d
...
@@ -21,6 +21,7 @@ import logging.config
...
@@ -21,6 +21,7 @@ import logging.config
import
yaml
import
yaml
from
string
import
Template
from
string
import
Template
import
os
import
os
import
signal
DEFAULT_LOG_CONFIG
=
Template
(
"""
DEFAULT_LOG_CONFIG
=
Template
(
"""
...
@@ -142,6 +143,19 @@ class LoggingConfig(Config):
...
@@ -142,6 +143,19 @@ class LoggingConfig(Config):
handler
=
logging
.
handlers
.
RotatingFileHandler
(
handler
=
logging
.
handlers
.
RotatingFileHandler
(
self
.
log_file
,
maxBytes
=
(
1000
*
1000
*
100
),
backupCount
=
3
self
.
log_file
,
maxBytes
=
(
1000
*
1000
*
100
),
backupCount
=
3
)
)
def
sighup
(
signum
,
stack
):
logger
.
info
(
"
Closing log file due to SIGHUP
"
)
handler
.
doRollover
()
logger
.
info
(
"
Opened new log file due to SIGHUP
"
)
# TODO(paul): obviously this is a terrible mechanism for
# stealing SIGHUP, because it means no other part of synapse
# can use it instead. If we want to catch SIGHUP anywhere
# else as well, I'd suggest we find a nicer way to broadcast
# it around.
if
getattr
(
signal
,
"
SIGHUP
"
):
signal
.
signal
(
signal
.
SIGHUP
,
sighup
)
else
:
else
:
handler
=
logging
.
StreamHandler
()
handler
=
logging
.
StreamHandler
()
handler
.
setFormatter
(
formatter
)
handler
.
setFormatter
(
formatter
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment