#2470: implementing log levels into sys log
This commit is contained in:
@@ -3,7 +3,7 @@ from pathlib import Path
|
||||
|
||||
from prettytable import MARKDOWN, PrettyTable
|
||||
|
||||
from primaite.simulator import SIM_OUTPUT
|
||||
from primaite.simulator import LogLevel, SIM_OUTPUT
|
||||
|
||||
|
||||
class _NotJSONFilter(logging.Filter):
|
||||
@@ -99,6 +99,9 @@ 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:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
self.logger.debug(msg)
|
||||
self._write_to_terminal(msg, "DEBUG", to_terminal)
|
||||
@@ -110,6 +113,9 @@ 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:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
self.logger.info(msg)
|
||||
self._write_to_terminal(msg, "INFO", to_terminal)
|
||||
@@ -121,6 +127,9 @@ 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:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
self.logger.warning(msg)
|
||||
self._write_to_terminal(msg, "WARNING", to_terminal)
|
||||
@@ -132,6 +141,9 @@ 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:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
self.logger.error(msg)
|
||||
self._write_to_terminal(msg, "ERROR", to_terminal)
|
||||
@@ -143,6 +155,9 @@ 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:
|
||||
return
|
||||
|
||||
if SIM_OUTPUT.save_sys_logs:
|
||||
self.logger.critical(msg)
|
||||
self._write_to_terminal(msg, "CRITICAL", to_terminal)
|
||||
|
||||
Reference in New Issue
Block a user