From 56a91aaf6f0efc4dd2872057879b227498e77c47 Mon Sep 17 00:00:00 2001 From: erpalma Date: Thu, 24 Jan 2019 08:52:56 +0100 Subject: [PATCH] fix logging to systemd and switch to stderr for warning and fatal --- lenovo_fix.py | 4 ++-- systemd/lenovo_fix.service | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lenovo_fix.py b/lenovo_fix.py index edc80f7..a220468 100755 --- a/lenovo_fix.py +++ b/lenovo_fix.py @@ -88,12 +88,12 @@ LIM = bcolors.YELLOW + bcolors.BOLD + 'LIM' + bcolors.RESET def fatal(msg, code=1): - print('[E] {:s}'.format(msg)) + print('[E] {:s}'.format(msg), file=sys.stderr) sys.exit(code) def warning(msg): - print('[W] {:s}'.format(msg)) + print('[W] {:s}'.format(msg), file=sys.stderr) def writemsr(msr, val): diff --git a/systemd/lenovo_fix.service b/systemd/lenovo_fix.service index d88205c..72fc963 100644 --- a/systemd/lenovo_fix.service +++ b/systemd/lenovo_fix.service @@ -4,6 +4,8 @@ Description=Stop Intel throttling [Service] Type=simple ExecStart=/opt/lenovo_fix/venv/bin/python3 /opt/lenovo_fix/lenovo_fix.py +# Setting PYTHONUNBUFFERED is necessary to see the output of this service in the journal +Environment=PYTHONUNBUFFERED=1 StandardOutput=syslog StandardError=syslog