Skip to content

Commit

Permalink
enhance logging: add the related disk filenames to log output
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Jan 26, 2024
1 parent 375627c commit 865a81b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libqmpbackup/qaclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def ping(self, timeout):
def fsfreeze(self, cmd):
"""Freeze / thaw filesystem"""
if cmd not in ["status", "freeze", "thaw"]:
raise Exception("Invalid command: " + cmd)
raise RuntimeError("Invalid command: " + cmd)

return getattr(self.qga, "fsfreeze" + "_" + cmd)()
3 changes: 2 additions & 1 deletion libqmpbackup/qmpcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ def progress(self, jobs, devices):
else 0
]
self.log.info(
"[%s] Wrote Offset: %s%% (%s of %s)",
"[%s:%s] Wrote Offset: %s%% (%s of %s)",
job["device"],
os.path.basename(device.filename),
prog[0],
job["offset"],
job["len"],
Expand Down
18 changes: 15 additions & 3 deletions libqmpbackup/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
This work is licensed under the terms of the GNU GPL, version 3. See
the LICENSE file in the top-level directory.
"""
import os
import logging
from collections import namedtuple

Expand Down Expand Up @@ -42,9 +43,12 @@ def get_block_devices(blockinfo, excluded_disks, included_disks):
continue

inserted = device["inserted"]
base_filename = os.path.basename(inserted["image"]["filename"])
if inserted["drv"] == "raw":
log.warning(
"Excluding device with raw format from backup: %s", device["device"]
"Excluding device with raw format from backup: [%s:%s]",
device["device"],
base_filename,
)
continue

Expand All @@ -65,11 +69,19 @@ def get_block_devices(blockinfo, excluded_disks, included_disks):
pass

if included_disks and not device["device"] in included_disks:
log.info("Device not in included disk list, ignoring: %s", device["device"])
log.info(
"Device not in included disk list, ignoring: [%s:%s]",
device["device"],
base_filename,
)
continue

if excluded_disks and device["device"] in excluded_disks:
logging.info("Excluding device from backup: %s", device["device"])
logging.info(
"Excluding device from backup: [%s:%s]",
device["device"],
base_filename,
)
continue

log.debug("Adding device to device list: %s", device)
Expand Down

0 comments on commit 865a81b

Please sign in to comment.