Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Nov 3, 2023
1 parent 4f6644c commit d960b41
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/tools/interop/idt/discovery/ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

import asyncio
import datetime
import os
Expand Down Expand Up @@ -61,7 +62,7 @@ def is_matter_device(service_uuid: str) -> bool:

def handle_device_states(self) -> None:
for device_id in self.devices_seen_last_time - self.devices_seen_this_time:
to_log = f"LOST {device_id}"
to_log = f"LOST {device_id}\n"
self.write_device_log(device_id, to_log)
self.devices_seen_last_time = self.devices_seen_this_time
self.devices_seen_this_time = set()
Expand Down
14 changes: 9 additions & 5 deletions src/tools/interop/idt/discovery/dnssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ class MatterDnssdListener(ServiceListener):
def __init__(self, artifact_dir: str) -> None:
super().__init__()
self.artifact_dir = artifact_dir
self.log_name = os.path.join(self.artifact_dir, create_standard_log_name("dnssd", "txt"))
self.logger = logger
self.discovered_matter_devices: [str, ServiceInfo] = {}

def write_log(self, line: str) -> None:
with open(self.log_name, "a+") as log_file:
def write_log(self, line: str, log_name:str) -> None:
with open(self.create_device_log_name(log_name), "a+") as log_file:
log_file.write(line)

def create_device_log_name(self, device_name) -> str:
return os.path.join(
self.artifact_dir,
create_standard_log_name(f"{device_name}_dnssd", "txt"))

@staticmethod
def log_addr(info: ServiceInfo) -> str:
ret = "\n"
Expand Down Expand Up @@ -83,7 +87,7 @@ def handle_service_info(
to_log += self.log_vid_pid(info)
to_log += self.log_addr(info)
self.logger.info(to_log)
self.write_log(to_log)
self.write_log(to_log, name)

def add_service(self, zc: Zeroconf, type_: str, name: str) -> None:
self.handle_service_info(zc, type_, name, "ADDED")
Expand All @@ -97,7 +101,7 @@ def remove_service(self, zc: Zeroconf, type_: str, name: str) -> None:
if name in self.discovered_matter_devices:
del self.discovered_matter_devices[name]
self.logger.warning(to_log)
self.write_log(to_log)
self.write_log(to_log, name)

def browse_interactive(self) -> None:
zc = Zeroconf()
Expand Down
2 changes: 1 addition & 1 deletion src/tools/interop/idt/probe/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ProberLinuxHost(p.GenericMatterProber):

def __init__(self, artifact_dir: str, dnssd_artifact_dir: str) -> None:
# TODO: Parity with macOS
super(ProberLinuxHost, self).__init__(artifact_dir, dnssd_artifact_dir)
super().__init__(artifact_dir, dnssd_artifact_dir)
self.logger = logger

def probe_v4(self, ipv4: str, port: str) -> None:
Expand Down
9 changes: 2 additions & 7 deletions src/tools/interop/idt/probe/mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
class ProberMacHost(p.GenericMatterProber):

def __init__(self, artifact_dir: str, dnssd_artifact_dir: str) -> None:
super(ProberMacHost, self).__init__(artifact_dir, dnssd_artifact_dir)
# TODO: Build out additional probes
super().__init__(artifact_dir, dnssd_artifact_dir)
self.logger = logger

def discover_targets_by_neighbor(self) -> None:
Expand All @@ -42,18 +43,12 @@ def check_routes(self) -> None:
def probe_v4(self, target: ProbeTarget) -> None:
self.logger.info("Ping")
self.run_command(f"ping -c {config.ping_count} {target.ip}")
self.logger.info("Route")
# TODO

def probe_v6(self, target: ProbeTarget) -> None:
self.logger.info("Ping")
self.run_command(f"ping6 -c {config.ping_count} {target.ip}")
self.logger.info("Route")
# TODO

def probe_v6_ll(self, target: ProbeTarget) -> None:
interface = get_ll_interface()
self.logger.info("Ping")
self.run_command(f"ping6 -c {config.ping_count} -I {interface} {target.ip}")
self.logger.info("Route")
# TODO

0 comments on commit d960b41

Please sign in to comment.