From 3ac20f770f3b32653068245b5caf40ad874ad95a Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Jun 05 2017 19:33:38 +0000 Subject: Remove the dependency on the systemd package The systemd package and journal logging does not offer a huge benefit over over simply logging to standard output and letting systemd drop that into the journal. Additionally, it makes greenwave more difficult to install by requiring systemd headers to be present. Combine this with the desire to deploy greenwave as a container in OpenShift, I'd say it's worth dropping the module. Signed-off-by: Jeremy Cline --- diff --git a/conf/settings.py.example b/conf/settings.py.example index cb5827f..a1357c2 100644 --- a/conf/settings.py.example +++ b/conf/settings.py.example @@ -1,6 +1,5 @@ # Copy this file to `conf/settings.py` to put it into effect. It overrides the values defined # in `greenwave/config.py`. SECRET_KEY = 'replace-me-with-something-random' -JOURNAL_LOGGING = False HOST= '0.0.0.0' PORT = 5005 diff --git a/greenwave/config.py b/greenwave/config.py index 6038664..1dd8ec1 100644 --- a/greenwave/config.py +++ b/greenwave/config.py @@ -15,7 +15,6 @@ class Config(object): A GreenWave Flask configuration. """ DEBUG = True - JOURNAL_LOGGING = False HOST = '0.0.0.0' PORT = 5005 PRODUCTION = False diff --git a/greenwave/logger.py b/greenwave/logger.py index 49e0c1a..7881b9b 100644 --- a/greenwave/logger.py +++ b/greenwave/logger.py @@ -11,28 +11,14 @@ import logging import sys -import systemd.journal -def log_to_stdout(app, level=logging.INFO): +def init_logging(app): + log_level = logging.DEBUG if app.debug else logging.INFO fmt = '[%(filename)s:%(lineno)d] ' if app.debug else '%(module)-12s ' fmt += '%(asctime)s %(levelname)-7s %(message)s' datefmt = '%Y-%m-%d %H:%M:%S' stream_handler = logging.StreamHandler(sys.stdout) - stream_handler.setLevel(level) + stream_handler.setLevel(log_level) stream_handler.setFormatter(logging.Formatter(fmt=fmt, datefmt=datefmt)) app.logger.addHandler(stream_handler) - - -def log_to_journal(app, level=logging.INFO): - journal_handler = systemd.journal.JournalHandler() - journal_handler.setLevel(level) - app.logger.addHandler(journal_handler) - - -def init_logging(app): - log_level = logging.DEBUG if app.debug else logging.INFO - if app.config['JOURNAL_LOGGING']: - log_to_journal(app, level=log_level) - else: - log_to_stdout(app, level=log_level) diff --git a/requirements.txt b/requirements.txt index 79c347b..30692b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ flask -systemd requests