Fix log prefix hijack in c_cmis.py#609
Merged
yxieca merged 2 commits intosonic-net:masterfrom Jan 25, 2026
Merged
Conversation
If any code imports c_cmis.py (indirectly for the most part) and has a logger session open already, their existing session will be re-opened with a new log tag, CCmisApi which is not desired. To fix this we match the logging in c_cmis.py with logging in neighboring files, it doesn't do any syslogging anymore. Libraries (rather than executables) probably shouldn't be syslogging on their own, and they certainly shouldn't hijack the log tag of the including executable.
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
@prgeor and @mihirpat1 would you mind taking a look please? |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a logging issue where the c_cmis.py library file hijacks the syslog identifier of any importing executable by removing unused logging code and dead functions.
Key Changes:
- Removed unused logger import and logging infrastructure that was overriding syslog identifiers
- Removed dead code (
_update_dict_if_vdm_key_existsmethod) that became unused in a previous PR - Removed unused
BYTELENGTHconstant
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mihirpat1
approved these changes
Nov 14, 2025
Contributor
Author
|
@prgeor @judyjoseph would you mind taking a look please? Thanks! |
Contributor
Author
|
@prgeor kind reminder, could you take a look please? Thanks! |
Contributor
Author
|
@prgeor Could you take a look please? This log hijacking makes it harder to debug other issues. Thanks! |
Contributor
Author
prgeor
approved these changes
Jan 25, 2026
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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
Remove calls to setting a syslog tag as there was no logging actually used in this module. The existing call to log a message was in dead code, therefore there was no need to setup a syslogger at all.
Motivation and Context
In python services using
sonic_py_common.loggerthe syslog identifier already set up by the executable/service can be overwritten when importing other modules.This log hijack is coming from a library:
sonic_platform_base/sonic_xcvr/api/public/c_cmis.pySearching in the syslog of a switch running SONiC we see logs with the
CCmisApithat shouldn't:If any code imports c_cmis.py (indirectly for the most part) and has a logger session open already, their existing session will be re-opened with a new log tag,
CCmisApiwhich is not desired.To fix this we remove this logging code entirely because the function where it is used became dead in #556
Libraries (rather than executables) probably shouldn't be syslogging on their own, and they certainly shouldn't hijack the log tag of the including executable.
Resolves sonic-net/sonic-buildimage#24489
How Has This Been Tested?
Before the fix:
Open an interactive python session and run this code:
Watch the syslog output:
Clearly the second log should also have had the tag
NATEAfter the fix:
Syslog entries should have been:
Additional Information (Optional)