diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-10-30 01:21:33 +0000 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-10-30 01:21:33 +0000 |
commit | b29517bd013b82302b1a73072da8bfc39564dc1a (patch) | |
tree | 363ac928a18f2432b6d53c27dde2f2efb34b16a8 /synapse/config | |
parent | fix mobile CSS layout (diff) | |
download | synapse-b29517bd013b82302b1a73072da8bfc39564dc1a.tar.xz |
Add a request-id to each log line
Diffstat (limited to 'synapse/config')
-rw-r--r-- | synapse/config/logger.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py index 56cd095433..2a59bf9d15 100644 --- a/synapse/config/logger.py +++ b/synapse/config/logger.py @@ -14,7 +14,7 @@ # limitations under the License. from ._base import Config - +from synapse.util.logcontext import LoggingContextFilter from twisted.python.log import PythonLoggingObserver import logging import logging.config @@ -45,7 +45,8 @@ class LoggingConfig(Config): def setup_logging(self): log_format = ( - '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(message)s' + "%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s" + " - %(message)s" ) if self.log_config is None: @@ -54,12 +55,20 @@ class LoggingConfig(Config): level = logging.DEBUG # FIXME: we need a logging.WARN for a -q quiet option + logger = logging.getLogger('') + logger.setLevel(level) + formatter = logging.Formatter(log_format) + if self.log_file: + handler = logging.FileHandler(self.log_file) + else: + handler = logging.StreamHandler() + print handler + handler.setFormatter(formatter) + + handler.addFilter(LoggingContextFilter(request="")) - logging.basicConfig( - level=level, - filename=self.log_file, - format=log_format - ) + logger.addHandler(handler) + logger.info("Test") else: logging.config.fileConfig(self.log_config) |