Skip to content

Commit

Permalink
fix: remove duplicate LogLevel initialization and minor mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Feb 26, 2025
1 parent 2dff6be commit 4d41ba9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
29 changes: 6 additions & 23 deletions opensourceleg/logging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@


class LogLevel(Enum):
"""
Enumerates the possible log levels.
Attributes:
DEBUG (int): Debug log level
INFO (int): Info log level
WARNING (int): Warning log level
ERROR (int): Error log level
CRITICAL (int): Critical log level
Examples:
>>> LogLevel.DEBUG
10
>>> LogLevel.INFO
20
"""

class LogLevel(int, Enum):
"""
Enum for log levels used by the Logger class.
Expand All @@ -64,6 +46,7 @@ class LogLevel(int, Enum):
ERROR: A more serious problem, the software has not been able to perform some function.
CRITICAL: A serious error, indicating that the program itself may be unable to continue running.
"""

DEBUG = logging.DEBUG
INFO = logging.INFO
WARNING = logging.WARNING
Expand Down Expand Up @@ -225,7 +208,7 @@ def _setup_file_handler(self) -> None:
self._file_handler.setFormatter(fmt=self._std_formatter)
self.addHandler(hdlr=self._file_handler)

def _ensure_file_handler(self):
def _ensure_file_handler(self) -> None:
if not hasattr(self, "_file_handler"):
self._setup_file_handler()

Expand Down Expand Up @@ -400,12 +383,12 @@ def flush_buffer(self) -> None:

if self._file is None:
self._file = open(self._csv_path, "w", newline="")
self._writer = csv.writer(self._file)
self._writer = csv.writer(self._file) # type: ignore[assignment]

if not self._header_written:
self._write_header()

self._writer.writerows(self._buffer)
self._writer.writerows(self._buffer) # type: ignore[attr-defined]
self._buffer.clear()
self._file.flush()

Expand All @@ -415,7 +398,7 @@ def _write_header(self) -> None:
This header is written only once per log file.
"""
header = list(self._var_names.values())
self._writer.writerow(header)
self._writer.writerow(header) # type: ignore[attr-defined]
self._header_written = True

def _generate_file_paths(self) -> None:
Expand Down Expand Up @@ -648,7 +631,7 @@ def file_max_bytes(self) -> int:
def file_backup_count(self) -> int:
"""
Get the number of backup log files to keep.
Returns:
int: The backup count.
"""
Expand Down
2 changes: 1 addition & 1 deletion tutorials/actuators/dephy/sensor_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)

with actpack:
for t in clock:
for _t in clock:
actpack.update()
LOGGER.info(
f"Motor Position: {actpack.motor_position}; "
Expand Down
2 changes: 1 addition & 1 deletion tutorials/actuators/dephy/voltage_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

with actpack:
actpack.set_control_mode(mode=CONTROL_MODES.VOLTAGE)

for t in clock:
actpack.update()

Expand Down

0 comments on commit 4d41ba9

Please sign in to comment.