Skip to content

Commit cf7bfa2

Browse files
Add the definition of log in script decode-syseeprom (sonic-net#3383)
#### What I did If there is something wrong getting eeprom while exectuing script `decode-syseeprom`, it will raise an exception and log the error. There was no definition of `log` in script `decode-syseeprom`, which will raise such error ``` Traceback (most recent call last): File "/usr/local/bin/decode-syseeprom", line 264, in <module> sys.exit(main()) ^^^^^^ File "/usr/local/bin/decode-syseeprom", line 246, in main print_serial(use_db) File "/usr/local/bin/decode-syseeprom", line 171, in print_serial eeprom = instantiate_eeprom_object() ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/bin/decode-syseeprom", line 36, in instantiate_eeprom_object log.log_error('Failed to obtain EEPROM object due to {}'.format(repr(e))) ^^^ NameError: name 'log' is not defined ``` In this PR, I add the definition of log to avoid such error. #### How I did it Add the definition of log. #### How to verify it ``` admin@vlab-01:~$ sudo decode-syseeprom -s Failed to read system EEPROM info ```
1 parent 9d206af commit cf7bfa2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/decode-syseeprom

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ import sys
1717

1818
import sonic_platform
1919
from sonic_platform_base.sonic_eeprom.eeprom_tlvinfo import TlvInfoDecoder
20-
from sonic_py_common import device_info
20+
from sonic_py_common import device_info, logger
2121
from swsscommon.swsscommon import SonicV2Connector
2222
from tabulate import tabulate
2323

2424

2525
EEPROM_INFO_TABLE = 'EEPROM_INFO'
26+
SYSLOG_IDENTIFIER = 'decode-syseeprom'
2627

28+
log = logger.Logger(SYSLOG_IDENTIFIER)
2729

2830
def instantiate_eeprom_object():
2931
eeprom = None

0 commit comments

Comments
 (0)