]> git.ipfire.org Git - people/ms/westferry.git/commitdiff
Enable logging to journald
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Dec 2021 15:09:36 +0000 (15:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Dec 2021 15:09:36 +0000 (15:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/westferry/__init__.py
src/westferry/logging.py [new file with mode: 0644]
src/westferry/ui/forms.py

index 53425ce67ed53ad847d78879a3fe27f58180308a..6db0a9acd5c40053501c1dfaa7ff3b7c536ce371 100644 (file)
@@ -86,6 +86,7 @@ westferry_PYTHON = \
        src/westferry/constants.py \
        src/westferry/application.py \
        src/westferry/i18n.py \
+       src/westferry/logging.py \
        src/westferry/services.py
 
 westferrydir = $(pythondir)/westferry
index 9bd1ba15a082eb47e252e0a1da9cbd7b060d4f0b..9660f1380f32be54c13c57fb6a4505789b9b383f 100644 (file)
@@ -19,4 +19,5 @@
 #                                                                             #
 ###############################################################################
 
+from . import logging
 from . import services
diff --git a/src/westferry/logging.py b/src/westferry/logging.py
new file mode 100644 (file)
index 0000000..337285d
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/python3
+###############################################################################
+#                                                                             #
+# Westferry - The IPFire web user interface                                   #
+# Copyright (C) 2021 IPFire development team                                  #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+import logging
+import systemd.journal
+
+# Initialize root logger
+log = logging.getLogger("westferry")
+log.propagate = False
+
+# Set logger into DEBUG mode by default
+log.setLevel(logging.DEBUG)
+
+# Enable logging to journald
+journal = systemd.journal.JournalHandler(
+       SYSLOG_IDENTIFIER=__name__,
+)
+log.addHandler(journal)
index abd85456ff9cddf40effc4429a3384bcc01b35cb..fca8adc61343fa1bfffe9aa20b8c9ca346c7db9b 100644 (file)
 #                                                                             #
 ###############################################################################
 
-import logging
-
 from . import base
 
+import logging
 log = logging.getLogger(__name__)
 
 class Form(object):