Skip to content

Bug: syslog identifier is hijacked to "CCmisApi" when importing sonic_platform #24489

@nate-nexthop

Description

@nate-nexthop

Is it platform specific

generic

Importance or Severity

High

Description of the bug

In python services using sonic_py_common.logger the syslog identifier already set up by the code can be overwritten when importing other modules.

This log hijack is coming from a library: sonic_platform_base/sonic_xcvr/api/public/c_cmis.py

SYSLOG_IDENTIFIER = "CCmisApi"
...
helper_logger = logger.Logger(SYSLOG_IDENTIFIER)
# This is the only log that this file has:
    helper_logger.log_debug('key {} not present in VDM'.format(new_key))

It seems like libraries shouldn't be syslogging, only services should.

Searching in the syslog of a switch running SONiC we see logs with the CCmisApi that shouldn't:

2025-11-11T13:20:03.440479+00:00 sonic CCmisApi: Failed to load platform Pcie module. Warning : No module named 'sonic_platform.pcie', fallback to load Pcie common utility.
2025 Nov 11 13:20:45.179454 gold228 NOTICE CCmisApi: System is ready

Steps to Reproduce

Open an interactive python session and run this code:

from sonic_py_common import logger
log = logger.Logger("NATE")
log.log_notice("Log 1")
import sonic_platform
log.log_notice("Log 2")

Watch the syslog output:

2025 Nov 11 13:47:29.002667 gold228-dut NOTICE NATE: Log 1
2025 Nov 11 13:48:28.406481 gold228-dut NOTICE CCmisApi: Log 2

Clearly the second log should also have had the tag NATE

Actual Behavior and Expected Behavior

Syslog entries should have been:

2025 Nov 11 13:47:29.002667 gold228-dut NOTICE NATE: Log 1
2025 Nov 11 13:48:28.406481 gold228-dut NOTICE NATE: Log 2

Relevant log output

Output of show version, show techsupport

Attach files (if any)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions