diff --git a/ct-app/core/components/baseclass.py b/ct-app/core/components/baseclass.py index 3ac22cec..c185916a 100644 --- a/ct-app/core/components/baseclass.py +++ b/ct-app/core/components/baseclass.py @@ -2,7 +2,7 @@ logging.basicConfig() logging.getLogger("asyncio").setLevel(logging.WARNING) -formatter = logging.Formatter("%(message)s") +formatter = logging.Formatter("%(asctime)s %(levelname)s:%(message)s") class Base: @@ -25,7 +25,7 @@ def class_prefix(cls) -> str: return f"{cls.__name__.upper()}_" def __format(self, message: str, color: str = "\033[0m"): - return f"{color}{self.print_prefix}\033[0m | {message}" + return f"{self.print_prefix} | {message}" def _print(self, message: str, color: str = "\033[0m"): print(self.__format(message, color)) diff --git a/ct-app/core/components/hoprd_api.py b/ct-app/core/components/hoprd_api.py index fced28b2..0cb7b5c6 100644 --- a/ct-app/core/components/hoprd_api.py +++ b/ct-app/core/components/hoprd_api.py @@ -43,6 +43,9 @@ def print_prefix(self) -> str: def __call_api( self, obj: Callable[..., object], method: str, *args, **kwargs ) -> tuple[bool, Optional[object]]: + self.debug( + f"Calling {obj.__name__}.{method} with kwargs: {kwargs}, args: {args}" + ) try: with ApiClient(self.configuration) as client: api_callback = getattr(obj(client), method) diff --git a/ct-app/core/core.py b/ct-app/core/core.py index a7486e35..ce181bc3 100644 --- a/ct-app/core/core.py +++ b/ct-app/core/core.py @@ -201,8 +201,8 @@ async def get_subgraph_data(self): self.debug(f"Fetched subgraph data ({len(results)} entries).") @flagguard - @connectguard @formalin("Getting topology data") + @connectguard async def get_topology_data(self): """ Gets a dictionary containing all unique source_peerId-source_address links @@ -346,6 +346,7 @@ async def distribute_rewards(self): @flagguard @formalin("Getting funding data") + @connectguard async def get_fundings(self): from_address = self.params.subgraph.from_address ct_safe_addresses = { diff --git a/ct-app/core/node.py b/ct-app/core/node.py index 5c5611eb..ce799c7f 100644 --- a/ct-app/core/node.py +++ b/ct-app/core/node.py @@ -104,6 +104,8 @@ async def healthcheck(self): if address := self.address: self.debug(f"Connection state: {await self.connected.get()}") HEALTH.labels(address.id).set(int(await self.connected.get())) + else: + self.warning("No address found") @flagguard @formalin("Retrieving balances") @@ -132,6 +134,7 @@ async def open_channels(self): self.debug(f"Addresses without channels: {len(addresses_without_channels)}") for address in addresses_without_channels: + self.debug(f"Opening channel to {address}") ok = await self.api.open_channel( address, f"{int(self.params.channel.funding_amount*1e18):d}", @@ -139,6 +142,8 @@ async def open_channels(self): if ok: self.debug(f"Opened channel to {address}") CHANNELS_OPENED.labels(self.address.id).inc() + else: + self.warning(f"Failed to open channel to {address}") OPEN_CHANNELS_CALLS.labels(self.address.id).inc() ADDRESSES_WOUT_CHANNELS.labels(self.address.id).set( @@ -158,10 +163,13 @@ async def close_incoming_channels(self): ] for channel in in_opens: + self.debug(f"Closing incoming channel {channel.channel_id}") ok = await self.api.close_channel(channel.channel_id) if ok: self.debug(f"Closed channel {channel.channel_id}") INCOMING_CHANNELS_CLOSED.labels(self.address.id).inc() + else: + self.warning(f"Failed to close channel {channel.channel_id}") CLOSE_INCOMING_CHANNELS_CALLS.labels(self.address.id).inc() @flagguard @@ -179,10 +187,13 @@ async def close_pending_channels(self): self.debug(f"Pending channels: {len(out_pendings)}") for channel in out_pendings: + self.debug(f"Closing pending channel {channel.channel_id}") ok = await self.api.close_channel(channel.channel_id) if ok: self.debug(f"Closed pending channel {channel.channel_id}") PENDING_CHANNELS_CLOSED.labels(self.address.id).inc() + else: + self.warning(f"Failed to close pending channel {channel.channel_id}") CLOSE_PENDING_CHANNELS_CALLS.labels(self.address.id).inc() @flagguard @@ -222,13 +233,14 @@ async def close_old_channels(self): self.info(f"Closing {len(channels_to_close)} old channels") for channel in channels_to_close: + self.debug(f"Closing channel {channel}") ok = await self.api.close_channel(channel) if ok: self.debug(f"Channel {channel} closed") OLD_CHANNELS_CLOSED.labels(self.address.id).inc() else: - self.debug(f"Failed to close channel {channel_id}") + self.warning(f"Failed to close channel {channel_id}") CLOSE_OLD_CHANNELS_CALLS.labels(self.address.id).inc() @@ -256,12 +268,15 @@ async def fund_channels(self): for channel in low_balances: if channel.destination_peer_id in peer_ids: + self.debug(f"Funding channel {channel.channel_id}") ok = await self.api.fund_channel( channel.channel_id, self.params.channel.funding_amount * 1e18 ) if ok: self.debug(f"Funded channel {channel.channel_id}") FUNDED_CHANNELS.labels(self.address.id).inc() + else: + self.warning(f"Failed to fund channel {channel.channel_id}") FUND_CHANNELS_CALLS.labels(self.address.id).inc() @flagguard @@ -340,6 +355,7 @@ async def get_total_channel_funds(self): results = await Utils.aggregatePeerBalanceInChannels(channels) if self.address.id not in results: + self.warning("Funding info not found") return entry = TopologyEntry.fromDict(self.address.id, results[self.address.id])