[write_standby]: Improve logging

Signed-off-by: Lawrence Lee <lawlee@microsoft.com>
This commit is contained in:
Lawrence Lee 2021-05-06 18:36:13 +00:00 committed by Ying Xie
parent fad5ec47b4
commit 69bae5b27a

View File

@ -2,11 +2,11 @@
import time import time
from sonic_py_common import logger as log
from swsscommon.swsscommon import ConfigDBConnector, DBConnector, FieldValuePairs, ProducerStateTable, SonicV2Connector from swsscommon.swsscommon import ConfigDBConnector, DBConnector, FieldValuePairs, ProducerStateTable, SonicV2Connector
from swsscommon.swsscommon import APPL_DB from swsscommon.swsscommon import APPL_DB
logger = logging.getLogger(__name__) logger = log.Logger('write_standby')
REDIS_SOCK_PATH = '/var/run/redis/redis.sock' REDIS_SOCK_PATH = '/var/run/redis/redis.sock'
@ -86,7 +86,7 @@ class MuxStateWriter(object):
(bool) True if the tunnel has been created (bool) True if the tunnel has been created
False if the timeout period is exceeded False if the timeout period is exceeded
""" """
logger.info("Waiting for tunnel {} with timeout {} seconds".format(self.tunnel_name, timeout)) logger.log_info("Waiting for tunnel {} with timeout {} seconds".format(self.tunnel_name, timeout))
start = time.time() start = time.time()
curr_time = time.time() curr_time = time.time()
@ -105,14 +105,14 @@ class MuxStateWriter(object):
intfs = self.get_all_mux_intfs() intfs = self.get_all_mux_intfs()
state = 'standby' state = 'standby'
if self.wait_for_tunnel(): if self.wait_for_tunnel():
logger.warning("Applying {} state to interfaces {}".format(state, intfs)) logger.log_warning("Applying {} state to interfaces {}".format(state, intfs))
producer_state_table = ProducerStateTable(self.appl_db, 'MUX_CABLE_TABLE') producer_state_table = ProducerStateTable(self.appl_db, 'MUX_CABLE_TABLE')
fvs = create_fvs(state=state) fvs = create_fvs(state=state)
for intf in intfs: for intf in intfs:
producer_state_table.set(intf, fvs) producer_state_table.set(intf, fvs)
else: else:
logger.error("Timed out waiting for tunnel {}, mux state will not be written".format(self.tunnel_name)) logger.log_error("Timed out waiting for tunnel {}, mux state will not be written".format(self.tunnel_name))
if __name__ == '__main__': if __name__ == '__main__':