Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 1f2d6bf

Browse files
committed
Use logging exc_info=True
Rather than rolling our own
1 parent 21c8381 commit 1f2d6bf

5 files changed

Lines changed: 8 additions & 26 deletions

File tree

virt-install

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def supports_pxe(guest):
8888
if forward and forward != "nat":
8989
return True
9090
except:
91-
_util.log_exception("Error checking if PXE supported")
91+
logging.debug("Error checking if PXE supported", exc_info=True)
9292
return True
9393

9494
return False
@@ -654,7 +654,7 @@ def start_install(guest, continue_inst, options):
654654
guest.connect_console(conscb)
655655

656656
except KeyboardInterrupt, e:
657-
cli.log_exception()
657+
logging.debug("", exc_info=True)
658658
guest.terminate_console()
659659
print_stderr(_("Domain install interrupted."))
660660
except RuntimeError, e:
@@ -1009,7 +1009,7 @@ if __name__ == "__main__":
10091009
except SystemExit, sys_e:
10101010
sys.exit(sys_e.code)
10111011
except KeyboardInterrupt:
1012-
cli.log_exception()
1012+
logging.debug("", exc_info=True)
10131013
print_stderr(_("Installation aborted at user request"))
10141014
except Exception, main_e:
10151015
fail(main_e)

virtinst/CloneManager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def _get_original_devices_info(self, xml):
611611
validate=validate)
612612
d.target = target
613613
except Exception, e:
614-
_util.log_exception(e)
614+
logging.debug("", exc_info=True)
615615
raise ValueError(_("Could not determine original disk "
616616
"information: %s" % str(e)))
617617
disks.append(d)

virtinst/DistroInstaller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ def set_location(self, val):
232232
volName=stuple)
233233
val = d.path
234234
except:
235-
_util.log_exception("Error validating install location")
235+
logging.debug("Error validating install location",
236+
exc_info=True)
236237
raise ValueError(_("Checking installer location failed: "
237238
"Could not find media '%s'." % str(val)))
238239
elif not validated:

virtinst/_util.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import re
2929
import commands
3030
import logging
31-
import traceback
3231
import platform
3332
import subprocess
3433

@@ -215,23 +214,6 @@ def fetch_all_guests(conn):
215214

216215
return (active, inactive)
217216

218-
def log_exception(msg=""):
219-
"""
220-
Log the most recent backtrace at the DEBUG level, rather than the
221-
ERROR level (which goes to stderr when used with the cli tools)
222-
223-
@param msg: Option message to log before the backtrace
224-
"""
225-
msg = str(msg)
226-
tb = "".join(traceback.format_exc()).strip()
227-
if tb != "None":
228-
if msg:
229-
msg += "\n"
230-
msg += tb
231-
232-
if msg:
233-
logging.debug(msg)
234-
235217
def set_xml_path(xml, path, newval):
236218
"""
237219
Set the passed xml xpath to the new value

virtinst/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
import virtinst
3737
from virtinst import _util
38-
from _util import log_exception
3938
from _util import listify
4039
from virtinst import _gettext as _
4140

@@ -346,7 +345,7 @@ def do_creds(creds, cbdata):
346345
try:
347346
return _do_creds(creds, cbdata)
348347
except:
349-
log_exception("Error in creds callback.")
348+
logging.debug("Error in creds callback.", exc_info=True)
350349
raise
351350

352351
def _do_creds(creds, cbdata_ignore):
@@ -438,7 +437,7 @@ def fail(msg, do_exit=True):
438437
Convenience function when failing in cli app
439438
"""
440439
logging.error(msg)
441-
log_exception()
440+
logging.debug("", exc_info=True)
442441
if do_exit:
443442
_fail_exit()
444443

0 commit comments

Comments
 (0)