From e99a57b074b59058e266fd953a345f65f9adacf9 Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Wed, 5 Feb 2025 15:08:17 -0700 Subject: [PATCH] Imrpoved logging --- sway_context_manager/workspace_tree.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sway_context_manager/workspace_tree.py b/sway_context_manager/workspace_tree.py index e029e58..2d9abbc 100644 --- a/sway_context_manager/workspace_tree.py +++ b/sway_context_manager/workspace_tree.py @@ -227,7 +227,7 @@ class WorkspaceGroup: return output.name return None - def get_match_level(self, output: OutputReply) -> OutputMatch: + def get_match_level(self, output: OutputReply, context: str = "") -> OutputMatch: """Get the match level score for the output.""" if self.make and self.model and self.serial: if ( @@ -236,13 +236,13 @@ class WorkspaceGroup: and output.serial == self.serial ): print( - f"Match level: ID_MATCH for {output.name} on group {self.name}", + f"Context {context}: ID_MATCH for {output.name} on group {self.name}", flush=True, ) return OutputMatch.ID_MATCH if output.name in self.output_names: print( - f"Match level: NAME_MATCH for {output.name} on group {self.name}", + f"Context {context}: NAME_MATCH for {output.name} on group {self.name}", flush=True, ) return OutputMatch.NAME_MATCH @@ -294,10 +294,16 @@ class WorkspaceContext: result = 0 for group in self.groups: group_result = max( - [group.get_match_level(output).value for output in outputs] + [ + group.get_match_level(output, context=self.name).value + for output in outputs + ] ) if group_result == 0: - print(f"Context {self.name}: failed to match group {group.name}") + print( + f"Context {self.name}: failed to match group {group.name}", + flush=True, + ) return 0 result += group_result return result