diff options
| author | Barry Warsaw | 2014-11-01 12:49:15 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2014-11-01 12:49:15 -0400 |
| commit | 8ab9c5111a05277e185b5e038bf12e13cd6df15e (patch) | |
| tree | 9307b9f2fb65a90bc4d61a2c97478b582a96de87 /src/mailman/core | |
| parent | b6bc505e45a2f1f4f99d7dd2cdd868d533270ee9 (diff) | |
| parent | fb38e482aa42edd4032a23e7c1f727066991fa62 (diff) | |
| download | mailman-8ab9c5111a05277e185b5e038bf12e13cd6df15e.tar.gz mailman-8ab9c5111a05277e185b5e038bf12e13cd6df15e.tar.zst mailman-8ab9c5111a05277e185b5e038bf12e13cd6df15e.zip | |
Database
--------
* The ORM layer, previously implemented with Storm, has been replaced by
SQLAlchemy, thanks to the fantastic work by Abhilash Raj and Aurélien
Bompard. Alembic is now used for all database schema migrations.
* The new logger `mailman.database` logs any errors at the database layer.
API
---
* Several changes to the internal API:
- `IListManager.mailing_lists` is guaranteed to be sorted in List-ID order.
- `IDomains.mailing_lists` is guaranteed to be sorted in List-ID order.
- Iteration over domains via the `IDomainManager` is guaranteed to be sorted
by `IDomain.mail_host` order.
- `ITemporaryDatabase` interface and all implementations are removed.
Diffstat (limited to 'src/mailman/core')
| -rw-r--r-- | src/mailman/core/docs/runner.rst | 4 | ||||
| -rw-r--r-- | src/mailman/core/logging.py | 53 |
2 files changed, 35 insertions, 22 deletions
diff --git a/src/mailman/core/docs/runner.rst b/src/mailman/core/docs/runner.rst index 28eab9203..e9fd21c57 100644 --- a/src/mailman/core/docs/runner.rst +++ b/src/mailman/core/docs/runner.rst @@ -73,3 +73,7 @@ on instance variables. version : 3 XXX More of the Runner API should be tested. + +.. + Clean up. + >>> config.pop('test-runner') diff --git a/src/mailman/core/logging.py b/src/mailman/core/logging.py index 43030436a..c9285af92 100644 --- a/src/mailman/core/logging.py +++ b/src/mailman/core/logging.py @@ -32,7 +32,6 @@ import codecs import logging from lazr.config import as_boolean, as_log_level - from mailman.config import config @@ -42,8 +41,7 @@ _handlers = {} # XXX I would love to simplify things and use Python's WatchedFileHandler, but # there are two problems. First, it's more difficult to handle the test -# suite's need to reopen the file handler to a different path. Does -# zope.testing's logger support fix this? +# suite's need to reopen the file handler to a different path. # # The other problem is that WatchedFileHandler doesn't really easily support # HUPing the process to reopen the log file. Now, maybe that's not a big deal @@ -104,6 +102,27 @@ class ReopenableFileHandler(logging.Handler): +def _init_logger(propagate, sub_name, log, logger_config): + # Get settings from log configuration file (or defaults). + log_format = logger_config.format + log_datefmt = logger_config.datefmt + # Propagation to the root logger is how we handle logging to stderr + # when the runners are not run as a subprocess of 'bin/mailman start'. + log.propagate = (as_boolean(logger_config.propagate) + if propagate is None else propagate) + # Set the logger's level. + log.setLevel(as_log_level(logger_config.level)) + # Create a formatter for this logger, then a handler, and link the + # formatter to the handler. + formatter = logging.Formatter(fmt=log_format, datefmt=log_datefmt) + path_str = logger_config.path + path_abs = os.path.normpath(os.path.join(config.LOG_DIR, path_str)) + handler = ReopenableFileHandler(sub_name, path_abs) + _handlers[sub_name] = handler + handler.setFormatter(formatter) + log.addHandler(handler) + + def initialize(propagate=None): """Initialize all logs. @@ -126,28 +145,18 @@ def initialize(propagate=None): continue if sub_name == 'locks': log = logging.getLogger('flufl.lock') + if sub_name == 'database': + # Set both the SQLAlchemy and Alembic logs to the mailman.database + # log configuration, essentially ignoring the alembic.cfg settings. + # Do the SQLAlchemy one first, then let the Alembic one fall + # through to the common code path. + log = logging.getLogger('sqlalchemy') + _init_logger(propagate, sub_name, log, logger_config) + log = logging.getLogger('alembic') else: logger_name = 'mailman.' + sub_name log = logging.getLogger(logger_name) - # Get settings from log configuration file (or defaults). - log_format = logger_config.format - log_datefmt = logger_config.datefmt - # Propagation to the root logger is how we handle logging to stderr - # when the runners are not run as a subprocess of 'bin/mailman start'. - log.propagate = (as_boolean(logger_config.propagate) - if propagate is None else propagate) - # Set the logger's level. - log.setLevel(as_log_level(logger_config.level)) - # Create a formatter for this logger, then a handler, and link the - # formatter to the handler. - formatter = logging.Formatter(fmt=log_format, datefmt=log_datefmt) - path_str = logger_config.path - path_abs = os.path.normpath(os.path.join(config.LOG_DIR, path_str)) - handler = ReopenableFileHandler(sub_name, path_abs) - _handlers[sub_name] = handler - handler.setFormatter(formatter) - log.addHandler(handler) - + _init_logger(propagate, sub_name, log, logger_config) def reopen(): |
