Skip to content

Commit

Permalink
Add the definition of log in script decode-syseeprom (sonic-net#3383
Browse files Browse the repository at this point in the history
)

#### 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
```
  • Loading branch information
yutongzhang-microsoft authored Jun 21, 2024
1 parent 9d206af commit cf7bfa2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/decode-syseeprom
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import sys

import sonic_platform
from sonic_platform_base.sonic_eeprom.eeprom_tlvinfo import TlvInfoDecoder
from sonic_py_common import device_info
from sonic_py_common import device_info, logger
from swsscommon.swsscommon import SonicV2Connector
from tabulate import tabulate


EEPROM_INFO_TABLE = 'EEPROM_INFO'
SYSLOG_IDENTIFIER = 'decode-syseeprom'

log = logger.Logger(SYSLOG_IDENTIFIER)

def instantiate_eeprom_object():
eeprom = None
Expand Down

0 comments on commit cf7bfa2

Please sign in to comment.