summaryrefslogtreecommitdiffstats
path: root/src/virtual
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2022-06-06 14:45:41 +0200
committerJose M. Guisado <jguisado@soleta.eu>2022-06-08 10:27:06 +0200
commit30fdcceea3efbd264b00d78fb0f86fd5a2ff8831 (patch)
treece0f5c1cf19fd19049ee5d51bdb8137c1bc974b2 /src/virtual
parent1ab981a539f3553021b3cf1642619338f2782af1 (diff)
src: improve logging
Adds new logging handler redirecting messages to the log file located in the Samba shared directory (applies to live mode clients, i.e: ogLive) Parses log level configuration from ogclient.json. See: { "opengnsys": { ... "log": "INFO", ... } ... } Adds --debug option to set root logger level to DEBUG when starting ogClient. Overrides log level from config file. In addition: - Replaces any occurence of print with a corresponding logging function. - Unsets log level for handlers, use root logger level instead. - Default level for root logger is INFO. - Replaces level from response log messages to debug (ogRest)
Diffstat (limited to 'src/virtual')
-rw-r--r--src/virtual/poweroffd.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/virtual/poweroffd.py b/src/virtual/poweroffd.py
index 63d08e1..83adee1 100644
--- a/src/virtual/poweroffd.py
+++ b/src/virtual/poweroffd.py
@@ -6,6 +6,7 @@
# Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
+import logging
from src.virtual.qmp import QEMUMonitorProtocol
from src.virtual.qmp import QMPCapabilitiesError, QMPConnectError
@@ -26,10 +27,10 @@ def init(host=QMP_DEFAULT_HOST, port=QMP_DEFAULT_PORT):
try:
qmpconn.connect()
except ConnectionRefusedError:
- print("Critical err: Connection refused")
+ logging.critical('poweroffd: Connection refused')
return None
except QMPCapabilitiesError as e:
- print("Error negotiating capabilities")
+ logging.critical('poweroffd: Error negotiating capabilities')
return None
return qmpconn
@@ -41,11 +42,11 @@ def run(qmpconn):
try:
qmp_ev = qmpconn.pull_event(wait=True)
except QMPConnectError as e:
- print("Error trying to pull an event")
+ logging.critical('Error trying to pull an event')
ret = -1
break
if is_shutdown_event(qmp_ev):
- print("Detected guest shutdown, let's go")
+ logging.info('Detected guest shutdown, powering off')
ret = 0
break