1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

modulebase: add ifaceobj.set_status calls in log_error and log_warn

Ticket:
Reviewed By: trivial
Testing Done:

This can be used by callers to set iface object status.
This commit is contained in:
Roopa Prabhu
2016-03-09 16:29:48 -08:00
parent ceed018d8e
commit b3745e05ed

View File

@ -34,19 +34,23 @@ class moduleBase(object):
self.CACHE = kargs.get('cache', False)
self.CACHE_FLAGS = kargs.get('cacheflags', 0x0)
def log_warn(self, str):
def log_warn(self, str, ifaceobj=None):
""" log a warning if err str is not one of which we should ignore """
if not self.ignore_error(str):
if self.logger.getEffectiveLevel() == logging.DEBUG:
traceback.print_stack()
self.logger.warn(str)
if ifaceobj:
ifaceobj.set_status(ifaceStatus.WARNING)
pass
def log_error(self, str):
def log_error(self, str, ifaceobj=None):
""" log an err if err str is not one of which we should ignore and raise an exception """
if not self.ignore_error(str):
if self.logger.getEffectiveLevel() == logging.DEBUG:
traceback.print_stack()
if ifaceobj:
ifaceobj.set_status(ifaceStatus.ERROR)
raise Exception(str)
else:
pass