Skip to content

Commit

Permalink
Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Oct 24, 2023
1 parent 5b6b325 commit 4ac762d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,27 @@ def __init__(self, platform):
self.target = "googlehomefoyer-pa.googleapis.com"

async def _probe_tracert_icmp_foyer(self) -> None:
self.logger.info(f"icmp traceroute to {self.target}")
Bash(f"sudo traceroute {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_tracert_udp_foyer(self) -> None:
self.logger.info(f"udp traceroute to {self.target}")
Bash(f"sudo traceroute -U -p 443 {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_tracert_tcp_foyer(self) -> None:
self.logger.info(f"tcp traceroute to {self.target}")
Bash(f"sudo traceroute -T -p 443 {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_ping_foyer(self) -> None:
self.logger.info(f"ping {self.target}")
Bash(f"ping -c 4 {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_dns_foyer(self) -> None:
self.logger.info(f"dig {self.target}")
Bash(f"dig {self.target} {self.command_suffix}", sync=True).start_command()

async def _probe_from_phone_ping_foyer(self) -> None:
self.logger.info(f"ping {self.target} from phone")
self.platform.run_adb_command(f"shell ping -c 4 {self.target} {self.command_suffix}")

async def probe_services(self) -> None:
Expand Down
9 changes: 5 additions & 4 deletions src/tools/interop/idt/discovery/ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@

import asyncio
import datetime
import logging
import os
import time

from bleak import AdvertisementData, BleakScanner, BLEDevice
from bleak.exc import BleakDBusError
import log
logger = log.get_logger(__file__)


class MatterBleScanner:

def __init__(self, artifact_dir: str):
self.artifact_dir = artifact_dir
self.logger = logging.getLogger(__file__)
self.logger = logger
self.devices_seen_last_time: set[str] = set()
self.devices_seen_this_time: set[str] = set()
self.throttle_seconds = 1
Expand All @@ -50,7 +51,7 @@ def write_device_log(self, device_name: str, to_write: str) -> None:
ts = datetime.datetime.now().isoformat(sep=' ', timespec='milliseconds')
to_write = f"{ts}\n{to_write}\n\n"
log_file.write(to_write)
print(to_write)
self.logger.info(to_write)

@staticmethod
def is_matter_device(service_uuid: str) -> bool:
Expand Down Expand Up @@ -100,5 +101,5 @@ def browse_interactive(self) -> None:
time.sleep(self.throttle_seconds)
asyncio.run(self.browse(scanner))
except BleakDBusError as e:
self.logger.warning(e)
self.logger.critical(e)
time.sleep(self.error_seconds)
7 changes: 4 additions & 3 deletions src/tools/interop/idt/discovery/dnssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
# limitations under the License.
#

import logging

from zeroconf import ServiceBrowser, ServiceInfo, ServiceListener, Zeroconf
import log
logger = log.get_logger(__file__)


_MDNS_TYPES = {
"_matterd._udp.local.": "COMMISSIONER",
Expand All @@ -32,7 +33,7 @@ class MatterDnssdListener(ServiceListener):
def __init__(self, artifact_dir: str) -> None:
super().__init__()
self.artifact_dir = artifact_dir
self.logger = logging.getLogger(__file__)
self.logger = logger

@staticmethod
def log_addr(info: ServiceInfo) -> str:
Expand Down

0 comments on commit 4ac762d

Please sign in to comment.