Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Add debug logs to write_eeprom #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import os
import threading
import time
import inspect
from sonic_py_common.logger import Logger
from sonic_py_common.general import check_output_pipe
from . import utils
Expand Down Expand Up @@ -528,12 +529,31 @@ def write_eeprom(self, offset, num_bytes, write_buffer):
Example:
mlxreg -d /dev/mst/mt52100_pciconf0 --reg_name MCIA --indexes slot_index=0,module=1,device_address=154,page_number=5,i2c_device_address=0x50,size=1,bank_number=0 --set dword[0]=0x01000000 -y
"""

logger.log_error(f'--- err:-5_debug --- Entered write_eeprom()')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having LOG ERR add ERR message to LOG. You should change it to NOTICE\INFO

stack_trace = ["sfp.write_eeprom()"]
for frame in inspect.stack()[1:]:
func_name = frame.function
cls_name = None
if "self" in frame.frame.f_locals:
cls_name = frame.frame.f_locals["self"].__class__.__name__
elif "cls" in frame.frame.f_locals:
cls_name = frame.frame.f_locals["cls"].__name__

if cls_name:
stack_trace.append(f"{cls_name}.{func_name}()")
else:
stack_trace.append(f"{func_name}()")
execution_flow = " --> ".join(reversed(stack_trace))
logger.log_error(f'--- err:-5_debug --- Call Stack: {execution_flow}')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having LOG ERR add ERR message to LOG. You should change it to NOTICE\INFO


if num_bytes != len(write_buffer):
logger.log_error("Error mismatch between buffer length and number of bytes to be written")
return False

while num_bytes > 0:
page_num, page, page_offset = self._get_page_and_page_offset(offset)
logger.log_error(f'--- err:-5_debug --- Attempt to write to: page={page}, offset={page_offset}')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having LOG ERR add ERR message to LOG. You should change it to NOTICE\INFO

if not page:
return False

Expand Down
Loading