Fixing logging used by sonic_platform_base classes to prevent log pollution - #761
Open
gordon-nexthop wants to merge 1 commit into
Open
gordon-nexthop wants to merge 1 commit into
gordon-nexthop wants to merge 1 commit into
Conversation
Signed-off-by: gordon-nexthop <gordon@nexthop.ai>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
gordon-nexthop
marked this pull request as ready for review
September 17, 2026 22:26
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Author
|
@benle7 would you mind taking a peak at this one! |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
nh-grecs Bot
pushed a commit
to nexthop-ai/sonic-platform-common
that referenced
this pull request
Sep 19, 2026
…lution rebuild-source: sonic-net#761 @ nexthop-ai/sonic-platform-common 8957705 [case: upstream:open]
nh-grecs Bot
pushed a commit
to nexthop-ai/sonic-platform-common
that referenced
this pull request
Sep 19, 2026
…lution rebuild-source: sonic-net/pull/761 @ nexthop-ai/sonic-platform-common 8957705 [case: upstream:open]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Convert the module-level loggers in
sonic_platform_basefromsonic_py_common.logger.Loggertosonic_py_common.syslogger.SysLogger:bmc_base.py,redfish_client.py,sed_mgmt_base.pyandbmc_fw_update.py.Loggeris a thin wrapper around the CsyslogAPI, and its constructor callssyslog.openlog(), which sets one identifier for the whole process. These modulesbuild a
Loggerat import time, so simply importing them renames every subsequentsyslogmessage emitted anywhere in the importing process.
SysLoggerinstead attaches aSysLogHandlerto a namedlogging.Logger, so the identifierbelongs to the logger instance rather than to the process. Importing a module can no longer
change how unrelated code in the same process is tagged, and each module still logs under its
own name. This is already the pattern used by
sonic_platform_base/sonic_xcvr/cdb/.Motivation and Context
fixes: #760
How Has This Been Tested?
On hardware. Nexthop 4010 (
x86_64-nexthop_4010-r0, HwSKU NH-4010, SONiC master,Python 3.13) — deliberately a non-BMC platform, since the bug reaches those too.
ZTP import chain. A probe that mirrors what
ztp-engine.pydoes — constructLogger('sonic-ztp'), log,import sonic_platform.platform, log again — withsyslog.openlogwrapped to record every identifier it is called with:openlog()idents, in order['sonic-ztp', 'redfish_client', 'bmc_base']bmc_base['sonic-ztp']sonic-ztpand the resulting
/var/log/sysloglines:The real ztp service.
systemctl start ztp(ZTP admin mode disabled, so it just bails)now logs under its own identifier, and no
bmc_base-tagged line was emitted by anything onthe switch after the swap:
No regression to BMC logging. Importing the modules and logging through them directly
still produces their own identifiers — now with the PID, since
SysLoggerformats as%(name)s[%(process)d]— andRedfishClientstill constructs:Platform API smoke test.
show platform summary,show platform psustatusanddocker exec pmon supervisorctl statuswere all healthy with the patched modules in place(pcied, psud, sensormond, stormond, syseepromd, thermalctld, xcvrd all RUNNING).
Additional Information (Optional)