Merged PR 350: #2510: cleaning up logs and add logging handler clearing to prevent duplicate...
## Summary - Cleaning up multiple logs that say the same thing - Added Nick's suggestion to clear log handlers before adding a handler on SysLog initialisation ## Test process *How have you tested this (if applicable)?* ## Checklist - [X] PR is linked to a **work item** - [X] **acceptance criteria** of linked ticket are met - [ ] performed **self-review** of the code - [ ] written **tests** for any new functionality added with this PR - [ ] updated the **documentation** if this PR changes or adds functionality - [ ] written/updated **design docs** if this PR implements new functionality - [ ] updated the **change log** - [ ] ran **pre-commit** checks for code style - [ ] attended to any **TO-DOs** left in the code #2510: cleaning up logs and add logging handler clearing to prevent duplicate logs Related work items: #2510
This commit is contained in:
@@ -1360,7 +1360,6 @@ class Node(SimComponent):
|
|||||||
self.software_manager.install(application)
|
self.software_manager.install(application)
|
||||||
application_instance = self.software_manager.software.get(str(application.__name__))
|
application_instance = self.software_manager.software.get(str(application.__name__))
|
||||||
self.applications[application_instance.uuid] = application_instance
|
self.applications[application_instance.uuid] = application_instance
|
||||||
self.sys_log.info(f"Installed application {application_instance.name}")
|
|
||||||
_LOGGER.debug(f"Added application {application_instance.name} to node {self.hostname}")
|
_LOGGER.debug(f"Added application {application_instance.name} to node {self.hostname}")
|
||||||
self._application_request_manager.add_request(
|
self._application_request_manager.add_request(
|
||||||
application_instance.name, RequestType(func=application_instance._request_manager)
|
application_instance.name, RequestType(func=application_instance._request_manager)
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ class Application(IOSoftware):
|
|||||||
"""Install Application."""
|
"""Install Application."""
|
||||||
super().install()
|
super().install()
|
||||||
if self.operating_state == ApplicationOperatingState.CLOSED:
|
if self.operating_state == ApplicationOperatingState.CLOSED:
|
||||||
self.sys_log.info(f"Installing Application {self.name}")
|
|
||||||
self.operating_state = ApplicationOperatingState.INSTALLING
|
self.operating_state = ApplicationOperatingState.INSTALLING
|
||||||
|
|
||||||
def receive(self, payload: Any, session_id: str, **kwargs) -> bool:
|
def receive(self, payload: Any, session_id: str, **kwargs) -> bool:
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ class SoftwareManager:
|
|||||||
software.software_manager = self
|
software.software_manager = self
|
||||||
self.software[software.name] = software
|
self.software[software.name] = software
|
||||||
self.port_protocol_mapping[(software.port, software.protocol)] = software
|
self.port_protocol_mapping[(software.port, software.protocol)] = software
|
||||||
self.sys_log.info(f"Installed {software.name}")
|
|
||||||
if isinstance(software, Application):
|
if isinstance(software, Application):
|
||||||
software.operating_state = ApplicationOperatingState.CLOSED
|
software.operating_state = ApplicationOperatingState.CLOSED
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class SysLog:
|
|||||||
file_handler.setFormatter(logging.Formatter(log_format))
|
file_handler.setFormatter(logging.Formatter(log_format))
|
||||||
|
|
||||||
self.logger = logging.getLogger(f"{self.hostname}_sys_log")
|
self.logger = logging.getLogger(f"{self.hostname}_sys_log")
|
||||||
|
self.logger.handlers.clear() # clear handlers
|
||||||
self.logger.setLevel(logging.DEBUG)
|
self.logger.setLevel(logging.DEBUG)
|
||||||
self.logger.addHandler(file_handler)
|
self.logger.addHandler(file_handler)
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ class NTPClient(Service):
|
|||||||
:param timestep: The current timestep number. (Amount of time since simulation episode began)
|
:param timestep: The current timestep number. (Amount of time since simulation episode began)
|
||||||
:type timestep: int
|
:type timestep: int
|
||||||
"""
|
"""
|
||||||
self.sys_log.info(f"{self.name} apply_timestep")
|
|
||||||
super().apply_timestep(timestep)
|
super().apply_timestep(timestep)
|
||||||
if self.operating_state == ServiceOperatingState.RUNNING:
|
if self.operating_state == ServiceOperatingState.RUNNING:
|
||||||
# request time from server
|
# request time from server
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ simulation:
|
|||||||
default_gateway: 192.168.10.1
|
default_gateway: 192.168.10.1
|
||||||
dns_server: 192.168.1.10
|
dns_server: 192.168.1.10
|
||||||
applications:
|
applications:
|
||||||
|
- type: RansomwareScript
|
||||||
- type: WebBrowser
|
- type: WebBrowser
|
||||||
options:
|
options:
|
||||||
target_url: http://arcd.com/users/
|
target_url: http://arcd.com/users/
|
||||||
|
|||||||
Reference in New Issue
Block a user