Skip to content

Commit 2f9bac9

Browse files
committed
refactor: replace println with log crate for proper logging
- Convert debug println! to log::debug! for conditional output - Convert error eprintln! to log::error! for proper error logging - Remove unused AxiosError import from useNotifications.test.ts
1 parent d18b3d8 commit 2f9bac9

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src-tauri/src/lib.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,20 @@ fn setup_tray(app: &mut App) -> Result<(), Box<dyn std::error::Error>> {
173173
};
174174

175175
if !should_process {
176-
println!("Click ignored (debounce)");
176+
log::debug!("Click ignored (debounce)");
177177
return;
178178
}
179179

180180
// Left-click: Toggle window visibility
181181
if let Some(window) = app.get_webview_window("main") {
182182
let is_visible = window.is_visible().unwrap_or(false);
183-
println!("Window visible: {}", is_visible);
183+
log::debug!("Window visible: {}", is_visible);
184184

185185
if is_visible {
186-
println!("Hiding window");
186+
log::debug!("Hiding window");
187187
let _ = window.hide();
188188
} else {
189-
println!("Showing window");
189+
log::debug!("Showing window");
190190

191191
// Position window - use absolute positioning for reliability
192192
use tauri::PhysicalPosition;
@@ -204,11 +204,11 @@ fn setup_tray(app: &mut App) -> Result<(), Box<dyn std::error::Error>> {
204204
let pos_x = (size.width as i32 - window_size.width as i32 - 20).max(0);
205205
let pos_y = 40; // Below menubar
206206

207-
println!("Screen size: {}x{}, Window size: {}x{}", size.width, size.height, window_size.width, window_size.height);
208-
println!("Positioning window at x={}, y={}", pos_x, pos_y);
207+
log::debug!("Screen size: {}x{}, Window size: {}x{}", size.width, size.height, window_size.width, window_size.height);
208+
log::debug!("Positioning window at x={}, y={}", pos_x, pos_y);
209209
(pos_x, pos_y)
210210
} else {
211-
println!("Could not get monitor, using default position");
211+
log::debug!("Could not get monitor, using default position");
212212
(1200, 40) // Fallback position
213213
}
214214
}
@@ -221,20 +221,20 @@ fn setup_tray(app: &mut App) -> Result<(), Box<dyn std::error::Error>> {
221221
let _ = window.set_position(PhysicalPosition::new(x, y));
222222

223223
// Show window
224-
println!("Calling show()");
224+
log::debug!("Calling show()");
225225
if let Err(e) = window.show() {
226-
println!("Error showing window: {}", e);
226+
log::error!("Error showing window: {}", e);
227227
}
228228

229-
println!("Calling set_focus()");
229+
log::debug!("Calling set_focus()");
230230
let _ = window.set_focus();
231231

232232
if window.is_minimized().unwrap_or(false) {
233-
println!("Unminimizing window");
233+
log::debug!("Unminimizing window");
234234
let _ = window.unminimize();
235235
}
236236

237-
println!("Window should be visible now");
237+
log::debug!("Window should be visible now");
238238
}
239239
}
240240
}
@@ -281,7 +281,7 @@ pub fn run() {
281281
// Check if any arg is a deep link (OAuth callback)
282282
for arg in &args {
283283
if arg.starts_with("gitify://oauth") || arg.starts_with("gitify://callback") {
284-
println!("OAuth callback from args: {}", arg);
284+
log::debug!("OAuth callback from args: {}", arg);
285285
let _ = app.emit("auth-callback", arg.clone());
286286
return;
287287
}
@@ -416,25 +416,25 @@ pub fn run() {
416416
#[cfg(any(target_os = "linux", target_os = "windows"))]
417417
{
418418
if let Err(e) = app.deep_link().register("gitify") {
419-
eprintln!("Failed to register deep link protocol: {}", e);
419+
log::error!("Failed to register deep link protocol: {}", e);
420420
}
421421
}
422422

423423
// Check for startup deep links (app launched via deep link)
424424
if let Ok(Some(urls)) = app.deep_link().get_current() {
425-
println!("Startup deep links: {:?}", urls);
425+
log::debug!("Startup deep links: {:?}", urls);
426426
let app_handle = app.handle().clone();
427427
for url in urls {
428428
let url_str = url.to_string();
429429
if url_str.starts_with("gitify://oauth") || url_str.starts_with("gitify://callback") {
430-
println!("Startup OAuth callback: {}", url_str);
430+
log::debug!("Startup OAuth callback: {}", url_str);
431431
// Delay emit slightly to ensure frontend is ready
432432
let handle = app_handle.clone();
433433
let url_clone = url_str.clone();
434434
std::thread::spawn(move || {
435435
std::thread::sleep(std::time::Duration::from_millis(500));
436436
if let Err(e) = handle.emit("auth-callback", url_clone) {
437-
eprintln!("Failed to emit startup auth-callback: {}", e);
437+
log::error!("Failed to emit startup auth-callback: {}", e);
438438
}
439439
});
440440
}
@@ -447,16 +447,16 @@ pub fn run() {
447447
// Listen for deep link events (OAuth callbacks)
448448
app.deep_link().on_open_url(move |event| {
449449
let urls = event.urls();
450-
println!("Deep link received: {:?}", urls);
450+
log::debug!("Deep link received: {:?}", urls);
451451

452452
for url in urls {
453453
let url_str = url.to_string();
454454
// Check if this is an OAuth callback
455455
if url_str.starts_with("gitify://oauth") || url_str.starts_with("gitify://callback") {
456-
println!("OAuth callback detected: {}", url_str);
456+
log::debug!("OAuth callback detected: {}", url_str);
457457
// Emit auth-callback event to frontend
458458
if let Err(e) = app_handle.emit("auth-callback", url_str.clone()) {
459-
eprintln!("Failed to emit auth-callback event: {}", e);
459+
log::error!("Failed to emit auth-callback event: {}", e);
460460
}
461461

462462
// Show and focus the window

src/hooks/useNotifications.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { act, renderHook, waitFor } from '@testing-library/react';
22

3-
import axios, { AxiosError } from 'axios';
3+
import axios from 'axios';
44
import nock from 'nock';
55

66
import { mockGitHubCloudAccount } from '../__mocks__/account-mocks';

0 commit comments

Comments
 (0)