-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfocus_tracker_app_gui.py
More file actions
581 lines (459 loc) · 24.9 KB
/
Copy pathfocus_tracker_app_gui.py
File metadata and controls
581 lines (459 loc) · 24.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
import pandas as pd
import numpy as np
import time
import threading
from datetime import datetime
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, accuracy_score
import os
import logging
import tkinter as tk
from tkinter import ttk, messagebox, scrolledtext
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import cv2
import mediapipe as mp
from eye_tracker import EyeTracker
from keyboard_tracker import KeyboardTracker
# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
class FocusTrackerAppGUI:
def __init__(self, root):
self.root = root
self.root.title("Focus Tracker")
self.root.geometry("900x700")
self.root.configure(bg="#f0f0f0")
# Initialize trackers
self.eye_tracker = EyeTracker()
self.keyboard_tracker = KeyboardTracker()
# Initialize session variables
self.session_start_time = None
self.is_session_active = False
self.focus_data = []
# Initialize machine learning model
self.model = RandomForestClassifier(n_estimators=100, random_state=42)
self.is_model_trained = False
# Create directories for data and reports
os.makedirs("data", exist_ok=True)
os.makedirs("reports", exist_ok=True)
# Create GUI elements
self.create_main_frame()
self.create_tracking_frame()
self.create_status_frame()
self.create_log_frame()
# Initialize matplotlib figure for live visualization
self.setup_visualization()
# Configure thread-safe GUI updates
self.root.after(1000, self.update_status)
def create_main_frame(self):
"""Create the main frame with application title and session controls"""
main_frame = ttk.Frame(self.root, padding="20 20 20 20")
main_frame.pack(fill=tk.BOTH, expand=False)
# Title label
title_label = ttk.Label(main_frame, text="Focus Tracker Application", font=("Helvetica", 18, "bold"))
title_label.pack(pady=10)
# Session control buttons
session_frame = ttk.Frame(main_frame)
session_frame.pack(fill=tk.X, pady=10)
self.start_session_btn = ttk.Button(session_frame, text="Start Session", command=self.start_session, width=15)
self.start_session_btn.pack(side=tk.LEFT, padx=5)
self.stop_session_btn = ttk.Button(session_frame, text="Stop Session", command=self.stop_session, width=15, state=tk.DISABLED)
self.stop_session_btn.pack(side=tk.LEFT, padx=5)
self.generate_report_btn = ttk.Button(session_frame, text="Generate Report", command=self.generate_focus_report, width=15, state=tk.DISABLED)
self.generate_report_btn.pack(side=tk.LEFT, padx=5)
def create_tracking_frame(self):
"""Create the tracking controls frame with buttons for eye and keyboard tracking"""
tracking_frame = ttk.LabelFrame(self.root, text="Tracking Controls", padding="10 10 10 10")
tracking_frame.pack(fill=tk.X, padx=20, pady=10)
# Eye tracking controls
eye_frame = ttk.Frame(tracking_frame)
eye_frame.pack(fill=tk.X, pady=5)
ttk.Label(eye_frame, text="Eye Tracking:", width=15).pack(side=tk.LEFT, padx=5)
self.start_eye_btn = ttk.Button(eye_frame, text="Start Eye Tracking", command=self.start_eye_tracking, width=20, state=tk.DISABLED)
self.start_eye_btn.pack(side=tk.LEFT, padx=5)
self.stop_eye_btn = ttk.Button(eye_frame, text="Stop Eye Tracking", command=self.stop_eye_tracking, width=20, state=tk.DISABLED)
self.stop_eye_btn.pack(side=tk.LEFT, padx=5)
self.eye_status_var = tk.StringVar(value="Not Started")
ttk.Label(eye_frame, textvariable=self.eye_status_var, width=15).pack(side=tk.LEFT, padx=5)
# Keyboard tracking controls
keyboard_frame = ttk.Frame(tracking_frame)
keyboard_frame.pack(fill=tk.X, pady=5)
ttk.Label(keyboard_frame, text="Keyboard Tracking:", width=15).pack(side=tk.LEFT, padx=5)
self.start_keyboard_btn = ttk.Button(keyboard_frame, text="Start Keyboard Tracking", command=self.start_keyboard_tracking, width=20, state=tk.DISABLED)
self.start_keyboard_btn.pack(side=tk.LEFT, padx=5)
self.stop_keyboard_btn = ttk.Button(keyboard_frame, text="Stop Keyboard Tracking", command=self.stop_keyboard_tracking, width=20, state=tk.DISABLED)
self.stop_keyboard_btn.pack(side=tk.LEFT, padx=5)
self.keyboard_status_var = tk.StringVar(value="Not Started")
ttk.Label(keyboard_frame, textvariable=self.keyboard_status_var, width=15).pack(side=tk.LEFT, padx=5)
def create_status_frame(self):
"""Create the status frame showing session information"""
status_frame = ttk.LabelFrame(self.root, text="Session Status", padding="10 10 10 10")
status_frame.pack(fill=tk.X, padx=20, pady=10)
# Session start time
time_frame = ttk.Frame(status_frame)
time_frame.pack(fill=tk.X, pady=5)
ttk.Label(time_frame, text="Start Time:", width=15).pack(side=tk.LEFT, padx=5)
self.start_time_var = tk.StringVar(value="Not Started")
ttk.Label(time_frame, textvariable=self.start_time_var).pack(side=tk.LEFT, padx=5)
# Data points
data_frame = ttk.Frame(status_frame)
data_frame.pack(fill=tk.X, pady=5)
ttk.Label(data_frame, text="Data Points:", width=15).pack(side=tk.LEFT, padx=5)
self.data_points_var = tk.StringVar(value="0")
ttk.Label(data_frame, textvariable=self.data_points_var).pack(side=tk.LEFT, padx=5)
# Current typing speed
typing_frame = ttk.Frame(status_frame)
typing_frame.pack(fill=tk.X, pady=5)
ttk.Label(typing_frame, text="Typing Speed:", width=15).pack(side=tk.LEFT, padx=5)
self.typing_speed_var = tk.StringVar(value="0 WPM")
ttk.Label(typing_frame, textvariable=self.typing_speed_var).pack(side=tk.LEFT, padx=5)
def create_log_frame(self):
"""Create the log frame for displaying application messages"""
log_frame = ttk.LabelFrame(self.root, text="Application Log", padding="10 10 10 10")
log_frame.pack(fill=tk.BOTH, expand=True, padx=20, pady=10)
self.log_text = scrolledtext.ScrolledText(log_frame, wrap=tk.WORD, width=100, height=10)
self.log_text.pack(fill=tk.BOTH, expand=True)
self.log_text.config(state=tk.DISABLED)
def setup_visualization(self):
"""Set up the matplotlib figure for live data visualization"""
viz_frame = ttk.LabelFrame(self.root, text="Live Data Visualization", padding="10 10 10 10")
viz_frame.pack(fill=tk.BOTH, expand=True, padx=20, pady=10)
# Create a matplotlib figure
self.fig, self.ax = plt.subplots(figsize=(8, 3), dpi=100)
self.canvas = FigureCanvasTkAgg(self.fig, master=viz_frame)
self.canvas.get_tk_widget().pack(fill=tk.BOTH, expand=True)
# Initialize empty plot
self.ax.set_title("Eye Focus & Typing Speed")
self.ax.set_xlabel("Time (s)")
self.ax.set_ylabel("Value")
self.ax.set_ylim(0, 100)
self.ax.grid(True)
# Initialize line objects for live updating
self.time_values = []
self.eye_focus_values = []
self.typing_speed_values = []
self.line_focus, = self.ax.plot([], [], 'r-', label='Eye Focus')
self.line_speed, = self.ax.plot([], [], 'b-', label='Typing Speed')
self.ax.legend(loc='upper right')
self.canvas.draw()
def log_message(self, message):
"""Log a message to the application log"""
self.log_text.config(state=tk.NORMAL)
timestamp = datetime.now().strftime("%H:%M:%S")
self.log_text.insert(tk.END, f"[{timestamp}] {message}\n")
self.log_text.see(tk.END)
self.log_text.config(state=tk.DISABLED)
def start_session(self):
"""Start a new focus tracking session"""
if self.is_session_active:
messagebox.showinfo("Session Active", "A session is already active. Please stop it before starting a new one.")
return
self.session_start_time = datetime.now()
self.is_session_active = True
self.focus_data = []
# Clear previous data from trackers
self.eye_tracker.clear_data()
self.keyboard_tracker.clear_data()
# Update GUI state
self.start_session_btn.config(state=tk.DISABLED)
self.stop_session_btn.config(state=tk.NORMAL)
self.generate_report_btn.config(state=tk.NORMAL)
self.start_eye_btn.config(state=tk.NORMAL)
self.start_keyboard_btn.config(state=tk.NORMAL)
# Update status labels
self.start_time_var.set(self.session_start_time.strftime("%Y-%m-%d %H:%M:%S"))
self.data_points_var.set("0")
# Log session start
self.log_message(f"Session started at: {self.session_start_time.strftime('%Y-%m-%d %H:%M:%S')}")
self.log_message("Use the buttons above to control tracking.")
def stop_session(self):
"""Stop the current focus tracking session"""
if not self.is_session_active:
messagebox.showinfo("No Active Session", "No active session to stop.")
return
# Stop both trackers if they are running
self.eye_tracker.stop_tracking()
self.keyboard_tracker.stop_tracking()
self.is_session_active = False
session_end_time = datetime.now()
# Update GUI state
self.start_session_btn.config(state=tk.NORMAL)
self.stop_session_btn.config(state=tk.DISABLED)
self.start_eye_btn.config(state=tk.DISABLED)
self.stop_eye_btn.config(state=tk.DISABLED)
self.start_keyboard_btn.config(state=tk.DISABLED)
self.stop_keyboard_btn.config(state=tk.DISABLED)
# Update status labels
self.eye_status_var.set("Not Started")
self.keyboard_status_var.set("Not Started")
# Log session end
self.log_message(f"Session ended at: {session_end_time.strftime('%Y-%m-%d %H:%M:%S')}")
duration = (session_end_time - self.session_start_time).total_seconds()
self.log_message(f"Session duration: {duration:.2f} seconds")
# Merge data from both trackers
self._merge_tracker_data()
# Train model
try:
self.train_model()
except Exception as e:
logger.error(f"Error processing session data: {e}")
self.log_message(f"Error: {e}")
def start_eye_tracking(self):
"""Start eye tracking"""
if not self.is_session_active:
messagebox.showinfo("No Session", "Please start a session first.")
return
self.eye_tracker.start_tracking()
# Update GUI state
self.start_eye_btn.config(state=tk.DISABLED)
self.stop_eye_btn.config(state=tk.NORMAL)
self.eye_status_var.set("Active")
# Log eye tracking start
self.log_message("Eye tracking started. Press 'ESC' in the window to stop.")
# Start a thread to periodically update focus data with keyboard speed
def update_focus_data():
while self.eye_tracker.is_tracking:
time.sleep(1) # Update every second
if self.eye_tracker.eye_data and self.is_session_active:
# Get the latest eye data
latest_eye_data = self.eye_tracker.eye_data[-1]
typing_speed = self.keyboard_tracker.get_current_typing_speed()
# Extract and validate eye focus value
eye_focus = latest_eye_data.get('eye_focus', 0.0)
# Log the raw focus value for debugging
self.log_message(f"Raw focus value: {eye_focus}")
# Ensure focus value is within valid range (0-1)
if not 0 <= eye_focus <= 1:
eye_focus = max(0.0, min(1.0, eye_focus))
# Add combined data to focus_data
with threading.Lock():
self.focus_data.append({
'timestamp': latest_eye_data['timestamp'],
'eye_focus': eye_focus,
'typing_speed': typing_speed
})
# Start the update thread
threading.Thread(target=update_focus_data, daemon=True).start()
def stop_eye_tracking(self):
"""Stop eye tracking"""
self.eye_tracker.stop_tracking()
# Update GUI state
self.start_eye_btn.config(state=tk.NORMAL)
self.stop_eye_btn.config(state=tk.DISABLED)
self.eye_status_var.set("Stopped")
# Log eye tracking stop
self.log_message("Eye tracking stopped.")
def start_keyboard_tracking(self):
"""Start keyboard tracking"""
if not self.is_session_active:
messagebox.showinfo("No Session", "Please start a session first.")
return
self.keyboard_tracker.start_tracking()
# Update GUI state
self.start_keyboard_btn.config(state=tk.DISABLED)
self.stop_keyboard_btn.config(state=tk.NORMAL)
self.keyboard_status_var.set("Active")
# Log keyboard tracking start
self.log_message("Keyboard tracking started. Type normally. Press 'ESC' to stop.")
def stop_keyboard_tracking(self):
"""Stop keyboard tracking"""
self.keyboard_tracker.stop_tracking()
# Update GUI state
self.start_keyboard_btn.config(state=tk.NORMAL)
self.stop_keyboard_btn.config(state=tk.DISABLED)
self.keyboard_status_var.set("Stopped")
# Log keyboard tracking stop
self.log_message("Keyboard tracking stopped.")
def _merge_tracker_data(self):
"""Merge data from both trackers for analysis"""
if not self.eye_tracker.eye_data and not self.keyboard_tracker.typing_data:
self.log_message("No data collected during the session.")
return
# If we don't have focus data (could happen if only one tracker was used), create it
if not self.focus_data:
# Create combined data based on timestamps
eye_data = self.eye_tracker.eye_data
typing_data = self.keyboard_tracker.typing_data
if eye_data and typing_data:
# Create DataFrames
eye_df = pd.DataFrame(eye_data)
typing_df = pd.DataFrame(typing_data)
# Resample both to 1-second intervals
eye_df['datetime'] = pd.to_datetime(eye_df['timestamp'], unit='s')
typing_df['datetime'] = pd.to_datetime(typing_df['timestamp'], unit='s')
# Set datetime as index
eye_df.set_index('datetime', inplace=True)
typing_df.set_index('datetime', inplace=True)
# Resample to 1-second intervals
eye_resampled = eye_df.resample('1S').mean().fillna(method='ffill')
typing_resampled = typing_df.resample('1S').mean().fillna(method='ffill')
# Merge the data
merged = pd.merge(eye_resampled, typing_resampled, left_index=True, right_index=True, how='outer')
merged = merged.interpolate()
# Convert back to the original format
for _, row in merged.iterrows():
if pd.notna(row['eye_focus']):
self.focus_data.append({
'timestamp': row.name.timestamp(),
'eye_focus': row['eye_focus'],
'typing_speed': row['time_between_keys'] if pd.notna(row['time_between_keys']) else 0
})
def train_model(self):
"""Train a machine learning model to classify focus levels"""
# Check if we have enough data to train
if len(self.focus_data) < 100:
self.log_message("Not enough data to train the model. Using heuristic for focus detection.")
return
# Convert focus data to a DataFrame
df = pd.DataFrame(self.focus_data)
# Calculate time differences between data points
df['time_diff'] = df['timestamp'].diff().fillna(0)
# Create features for the model
features = df[['eye_focus', 'typing_speed', 'time_diff']].values
# Create labels (1 for focused, 0 for not focused) based on thresholds
df['focused'] = 0
df.loc[(df['eye_focus'] > 0.7) & (df['typing_speed'] > 30), 'focused'] = 1
labels = df['focused'].values
# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(features, labels, test_size=0.2, random_state=42)
# Train the model
self.model.fit(X_train, y_train)
# Evaluate the model
y_pred = self.model.predict(X_test)
self.log_message(f"Model Accuracy: {accuracy_score(y_test, y_pred):.2f}")
self.is_model_trained = True
def generate_focus_report(self):
"""Generate a comprehensive report on focus levels"""
if not self.focus_data:
messagebox.showinfo("No Data", "No focus data available to generate a report.")
return
# Convert focus data to a DataFrame
df = pd.DataFrame(self.focus_data)
# Calculate focus metrics
total_time = df['timestamp'].max() - df['timestamp'].min() if len(df) > 1 else 0
# Ensure focus values are within valid range for reporting
df['eye_focus'] = df['eye_focus'].apply(lambda x: max(0.0, min(1.0, x)))
# Determine focus levels using trained model or heuristics
if self.is_model_trained and len(df) >= 10:
# Prepare features for prediction
df['time_diff'] = df['timestamp'].diff().fillna(0)
features = df[['eye_focus', 'typing_speed', 'time_diff']].values
# Predict focus levels
df['focused'] = self.model.predict(features)
else:
# Use more balanced heuristic for focus detection
df['focused'] = 0
# Less strict thresholds to better reflect actual focus
df.loc[(df['eye_focus'] > 0.3) & (df['typing_speed'] > 10), 'focused'] = 1
# Calculate overall focus percentage
focus_percentage = df['focused'].mean() * 100
# Generate timestamp for report files
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
report_file = f"reports/focus_report_{timestamp}.png"
# Create a detailed report with multiple visualizations
fig = plt.figure(figsize=(12, 10), dpi=100)
# 1. Focus over time
ax1 = fig.add_subplot(321)
ax1.plot(df['timestamp'] - df['timestamp'].min(), df['eye_focus'], 'r-')
ax1.set_title('Eye Focus Over Time')
ax1.set_xlabel('Time (s)')
ax1.set_ylabel('Focus Level')
ax1.grid(True)
# 2. Typing speed over time
ax2 = fig.add_subplot(322)
ax2.plot(df['timestamp'] - df['timestamp'].min(), df['typing_speed'], 'b-')
ax2.set_title('Typing Speed Over Time')
ax2.set_xlabel('Time (s)')
ax2.set_ylabel('Words Per Minute')
ax2.grid(True)
# 3. Focus distribution
ax3 = fig.add_subplot(323)
ax3.hist(df['eye_focus'], bins=20, alpha=0.7, color='r')
ax3.set_title('Eye Focus Distribution')
ax3.set_xlabel('Focus Level')
ax3.set_ylabel('Frequency')
ax3.grid(True)
# 4. Typing speed distribution
ax4 = fig.add_subplot(324)
ax4.hist(df['typing_speed'][df['typing_speed'] > 0], bins=20, alpha=0.7, color='b')
ax4.set_title('Typing Speed Distribution')
ax4.set_xlabel('Words Per Minute')
ax4.set_ylabel('Frequency')
ax4.grid(True)
# 5. Focus vs. Typing speed scatter plot
ax5 = fig.add_subplot(325)
scatter = ax5.scatter(df['typing_speed'], df['eye_focus'], c=df['focused'], cmap='viridis', alpha=0.6)
ax5.set_title('Focus vs. Typing Speed')
ax5.set_xlabel('Typing Speed (WPM)')
ax5.set_ylabel('Eye Focus Level')
ax5.grid(True)
fig.colorbar(scatter, ax=ax5, label='Focused (1) / Not Focused (0)')
# 6. Session information
ax6 = fig.add_subplot(326)
ax6.axis('off')
# Generate keyboard report if available
keyboard_report = ""
if self.keyboard_tracker.typing_data:
keyboard_report = self.keyboard_tracker.generate_typing_report()
session_info = (
f"======= Session Report =======\n" +
f"Session Start: {self.session_start_time.strftime('%Y-%m-%d %H:%M:%S')}\n" +
f"Total Duration: {total_time:.2f} seconds\n" +
f"Overall Focus Percentage: {focus_percentage:.1f}%\n" +
f"Average Typing Speed: {df['typing_speed'].mean():.1f} WPM\n" +
f"Average Eye Focus Level: {df['eye_focus'].mean():.3f}\n" +
"============================\n\n" +
keyboard_report
)
ax6.text(0.05, 0.95, session_info, ha="left", va="top", fontsize=9, family='monospace')
# Save the figure
plt.tight_layout()
plt.savefig(report_file)
# Save detailed data
data_file = f"reports/focus_data_{timestamp}.csv"
df.to_csv(data_file, index=False)
# Log report generation
self.log_message(f"Report generated: {report_file}")
self.log_message(f"Detailed data saved: {data_file}")
self.log_message(f"Overall focus percentage: {focus_percentage:.1f}%")
# Show the plot in a new window
plt.show()
def update_status(self):
"""Update the status labels and live visualization"""
# Update data points count
self.data_points_var.set(str(len(self.focus_data)))
# Update typing speed
typing_speed = self.keyboard_tracker.get_current_typing_speed()
self.typing_speed_var.set(f"{typing_speed:.1f} WPM")
# Update live visualization
if self.is_session_active and self.focus_data:
# Get the latest 60 data points for visualization
recent_data = self.focus_data[-60:]
# Update plot data
self.time_values = [t['timestamp'] - recent_data[0]['timestamp'] for t in recent_data]
# Scale eye focus values to 0-100 for visualization with proper clamping
self.eye_focus_values = [min(1.0, max(0.0, t['eye_focus'])) * 100 for t in recent_data]
# Ensure typing speeds don't exceed 100 for visualization
self.typing_speed_values = [min(t['typing_speed'], 100) for t in recent_data] # Cap at 100
# Update line objects
self.line_focus.set_data(self.time_values, self.eye_focus_values)
self.line_speed.set_data(self.time_values, self.typing_speed_values)
# Adjust plot limits
if self.time_values:
self.ax.set_xlim(0, max(self.time_values) + 5)
# Redraw the canvas
self.canvas.draw()
# Schedule next update
self.root.after(1000, self.update_status)
# Main function to run the application
if __name__ == "__main__":
try:
root = tk.Tk()
app = FocusTrackerAppGUI(root)
root.mainloop()
except KeyboardInterrupt:
print("\nApplication interrupted by user.")
except Exception as e:
logger.error(f"Application error: {e}")