Add message to log area.
(self, message: str, save_to_file: bool = True)
| 1121 | # Logging |
| 1122 | # ========================================================================= |
| 1123 | def _log(self, message: str, save_to_file: bool = True): |
| 1124 | """Add message to log area.""" |
| 1125 | timestamp = datetime.now().strftime("%H:%M:%S") |
| 1126 | formatted = f"[{timestamp}] {message}" |
| 1127 | |
| 1128 | self.log_area.configure(state="normal") |
| 1129 | self.log_area.insert("end", f"{formatted}\n") |
| 1130 | self.log_area.see("end") |
| 1131 | self.log_area.configure(state="disabled") |
| 1132 | |
| 1133 | if save_to_file: |
| 1134 | try: |
| 1135 | with open(LOG_FILE, "a", encoding="utf-8") as f: |
| 1136 | f.write(f"{formatted}\n") |
| 1137 | except Exception: |
| 1138 | pass |
| 1139 | |
| 1140 | def _clear_logs(self): |
| 1141 | """Clear log area.""" |
no test coverage detected