Skip to content

Commit

Permalink
[xcvrd][thermalctld] Add logger instances for helper functions and cl…
Browse files Browse the repository at this point in the history
…asses (sonic-net#82)

Previous commit to transition to importing sonic-py-common accidentally replaced all `logger` instances in xcvrd with `self`, although not all of these instances resided in the `DaemonXcvrd` class, breaking them. Here we add a global Logger instance for these references to use. Eventually we should refactor so that there is only one Logger instance created by xcvrd, not two.

- Also rename class names using PascalCase for consistency across the codebase.
- Also add Logger instance to ThermalMonitor class in thermalctld
  • Loading branch information
jleveque authored Aug 8, 2020
1 parent 8e0704e commit da3dfbb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 47 deletions.
11 changes: 7 additions & 4 deletions sonic-thermalctld/scripts/thermalctld
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ class ThermalMonitor(ProcessTaskBase):
:param chassis: Object representing a platform chassis
"""
ProcessTaskBase.__init__(self)

# TODO: Refactor to eliminate the need for this Logger instance
self.logger = logger.Logger(SYSLOG_IDENTIFIER)
self.fan_updater = FanUpdater(SYSLOG_IDENTIFIER, chassis)
self.temperature_updater = TemperatureUpdater(SYSLOG_IDENTIFIER, chassis)

Expand All @@ -574,7 +577,7 @@ class ThermalMonitor(ProcessTaskBase):
Thread function to handle Fan status update and temperature status update
:return:
"""
self.log_info("Start thermal monitoring loop")
self.logger.log_info("Start thermal monitoring loop")

# Start loop to update fan, temperature info in DB periodically
wait_time = ThermalMonitor.INITIAL_INTERVAL
Expand All @@ -589,13 +592,13 @@ class ThermalMonitor(ProcessTaskBase):
wait_time = ThermalMonitor.INITIAL_INTERVAL

if elapse > ThermalMonitor.UPDATE_ELAPSE_THRESHOLD:
self.log_warning('Update fan and temperature status takes {} seconds, '
'there might be performance risk'.format(elapse))
self.logger.log_warning('Update fan and temperature status takes {} seconds, '
'there might be performance risk'.format(elapse))

self.fan_updater.deinit()
self.temperature_updater.deinit()

self.log_info("Stop thermal monitoring loop")
self.logger.log_info("Stop thermal monitoring loop")


#
Expand Down
Loading

0 comments on commit da3dfbb

Please sign in to comment.