#2470: implement PR suggestions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Warning: SIM_OUTPUT is a mutable global variable for the simulation output directory."""
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from enum import IntEnum
|
||||
from pathlib import Path
|
||||
|
||||
from primaite import _PRIMAITE_ROOT
|
||||
@@ -8,20 +8,18 @@ from primaite import _PRIMAITE_ROOT
|
||||
__all__ = ["SIM_OUTPUT"]
|
||||
|
||||
|
||||
class LogLevel(Enum):
|
||||
class LogLevel(IntEnum):
|
||||
"""Enum containing all the available log levels for PrimAITE simulation output."""
|
||||
|
||||
OFF = 999
|
||||
"""No logs will be output to terminal or log file."""
|
||||
DEBUG = 1
|
||||
DEBUG = 10
|
||||
"""Debug items will be output to terminal or log file."""
|
||||
INFO = 2
|
||||
INFO = 20
|
||||
"""Info items will be output to terminal or log file."""
|
||||
WARNING = 3
|
||||
WARNING = 30
|
||||
"""Warnings will be output to terminal or log file."""
|
||||
ERROR = 4
|
||||
ERROR = 40
|
||||
"""Errors will be output to terminal or log file."""
|
||||
CRITICAL = 5
|
||||
CRITICAL = 50
|
||||
"""Critical errors will be output to terminal or log file."""
|
||||
|
||||
|
||||
@@ -33,7 +31,7 @@ class _SimOutput:
|
||||
self.save_pcap_logs: bool = False
|
||||
self.save_sys_logs: bool = False
|
||||
self.write_sys_log_to_terminal: bool = False
|
||||
self.log_level: LogLevel = LogLevel.INFO # default log level is at INFO
|
||||
self.sys_log_level: LogLevel = LogLevel.INFO # default log level is at INFO
|
||||
|
||||
@property
|
||||
def path(self) -> Path:
|
||||
|
||||
@@ -99,7 +99,7 @@ class SysLog:
|
||||
:param msg: The message to be logged.
|
||||
:param to_terminal: If True, prints to the terminal too.
|
||||
"""
|
||||
if SIM_OUTPUT.log_level.value > LogLevel.DEBUG.value:
|
||||
if SIM_OUTPUT.sys_log_level > LogLevel.DEBUG:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
@@ -113,7 +113,7 @@ class SysLog:
|
||||
:param msg: The message to be logged.
|
||||
:param to_terminal: If True, prints to the terminal too.
|
||||
"""
|
||||
if SIM_OUTPUT.log_level.value > LogLevel.INFO.value:
|
||||
if SIM_OUTPUT.sys_log_level > LogLevel.INFO:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
@@ -127,7 +127,7 @@ class SysLog:
|
||||
:param msg: The message to be logged.
|
||||
:param to_terminal: If True, prints to the terminal too.
|
||||
"""
|
||||
if SIM_OUTPUT.log_level.value > LogLevel.WARNING.value:
|
||||
if SIM_OUTPUT.sys_log_level > LogLevel.WARNING:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
@@ -141,7 +141,7 @@ class SysLog:
|
||||
:param msg: The message to be logged.
|
||||
:param to_terminal: If True, prints to the terminal too.
|
||||
"""
|
||||
if SIM_OUTPUT.log_level.value > LogLevel.ERROR.value:
|
||||
if SIM_OUTPUT.sys_log_level > LogLevel.ERROR:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
@@ -155,7 +155,7 @@ class SysLog:
|
||||
:param msg: The message to be logged.
|
||||
:param to_terminal: If True, prints to the terminal too.
|
||||
"""
|
||||
if LogLevel.CRITICAL.value < SIM_OUTPUT.log_level.value:
|
||||
if LogLevel.CRITICAL < SIM_OUTPUT.sys_log_level:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
|
||||
Reference in New Issue
Block a user