From aea09ba1da612710e725692a097b807aaca95007 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Wed, 16 Oct 2019 02:29:45 +0800 Subject: [PATCH] [sonic_platform] Correct the wrong log identifiers (#3596) --- .../mellanox/mlnx-platform-api/sonic_platform/chassis.py | 3 +-- platform/mellanox/mlnx-platform-api/sonic_platform/psu.py | 3 +-- platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py | 3 +-- .../mellanox/mlnx-platform-api/sonic_platform/sfp_event.py | 4 +--- .../mellanox/mlnx-platform-api/sonic_platform/thermal.py | 3 +-- src/sonic-daemon-base/sonic_daemon_base/daemon_base.py | 7 +++++-- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py index f5c7c04a4204..f964bf46fe88 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py @@ -39,8 +39,7 @@ REBOOT_CAUSE_FILE_LENGTH = 1 # Global logger class instance -SYSLOG_IDENTIFIER = "mlnx-chassis-api" -logger = Logger(SYSLOG_IDENTIFIER) +logger = Logger() # magic code defnition for port number, qsfp port position of each hwsku # port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py index a6f217d82bd3..0789f67e4f09 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py @@ -17,8 +17,7 @@ raise ImportError (str(e) + "- required module not found") # Global logger class instance -SYSLOG_IDENTIFIER = "mlnx-psu-api" -logger = Logger(SYSLOG_IDENTIFIER) +logger = Logger() psu_list = [] diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py index be59451a8cb7..dac6a8e4d4d6 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py @@ -188,8 +188,7 @@ NVE_MASK = PORT_TYPE_MASK & (PORT_TYPE_NVE << PORT_TYPE_OFFSET) # Global logger class instance -SYSLOG_IDENTIFIER = "mlnx-sfp" -logger = Logger(SYSLOG_IDENTIFIER) +logger = Logger() class SFP(SfpBase): """Platform-specific SFP class""" diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py index 439df785b24e..e92884fc3f33 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py @@ -11,8 +11,6 @@ from python_sdk_api.sx_api import * from sonic_daemon_base.daemon_base import Logger -SYSLOG_IDENTIFIER = "sfp-event" - SDK_SFP_STATE_IN = 0x1 SDK_SFP_STATE_OUT = 0x2 STATUS_PLUGIN = '1' @@ -34,7 +32,7 @@ PMPE_PACKET_SIZE = 2000 -logger = Logger(SYSLOG_IDENTIFIER) +logger = Logger() class sfp_event: ''' Listen to plugin/plugout cable events ''' diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py index 6614e368e547..6862b3fb258b 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py @@ -19,8 +19,7 @@ raise ImportError (str(e) + "- required module not found") # Global logger class instance -SYSLOG_IDENTIFIER = "mlnx-thermal-api" -logger = Logger(SYSLOG_IDENTIFIER) +logger = Logger() THERMAL_DEV_CATEGORY_CPU_CORE = "cpu_core" THERMAL_DEV_CATEGORY_CPU_PACK = "cpu_pack" diff --git a/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py b/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py index afdb189de672..a0a5bff0a297 100644 --- a/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py +++ b/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py @@ -48,9 +48,12 @@ def db_connect(db): # class Logger(object): - def __init__(self, syslog_identifier): + def __init__(self, syslog_identifier = None): self.syslog = syslog - self.syslog.openlog(ident=syslog_identifier, logoption=self.syslog.LOG_NDELAY, facility=self.syslog.LOG_DAEMON) + if syslog_identifier is None: + self.syslog.openlog() + else: + self.syslog.openlog(ident=syslog_identifier, logoption=self.syslog.LOG_NDELAY, facility=self.syslog.LOG_DAEMON) def __del__(self): self.syslog.closelog()