Replace println with tracing logs

This commit is contained in:
Avery 2024-01-24 11:46:25 -05:00
parent 5c74cf6eb7
commit f412b5909f
16 changed files with 43 additions and 23 deletions

View File

@ -1,5 +1,6 @@
use adw::prelude::*;
use relm4::{adw, gtk, prelude::*, Component, ComponentParts};
use tracing::error;
use uuid::Uuid;
use crate::{
@ -171,7 +172,7 @@ impl Component for AddAccountDialog {
root.close();
}
AddAccountCommandOutput::SignInFail(err) => {
println!("Sign in failed: {:#?}", err);
error!("Sign in failed: {:#?}", err);
sender.input(AddAccountInput::Toast(err.to_string()));
self.valid = ValidationState::Invalid;
}

View File

@ -2,6 +2,7 @@ use std::{cell::RefCell, sync::Arc, time::Duration};
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use tracing::warn;
use crate::{
utils::round::round_one_place,
@ -116,7 +117,7 @@ impl From<VideoPlayerBackendPreference> for Arc<RefCell<dyn VideoPlayerBackend>>
#[cfg(not(feature = "gst"))]
{
println!("GStreamer backend not available, falling back to MPV backend");
warn!("GStreamer backend not available, falling back to MPV backend");
Arc::<RefCell<VideoPlayerBackendMpv>>::default()
}
}

View File

@ -3,6 +3,7 @@ use std::collections::VecDeque;
use anyhow::Result;
use reqwest::{StatusCode, Url};
use serde::{Deserialize, Serialize};
use tracing::error;
use uuid::Uuid;
use crate::jellyfin_api::{
@ -69,7 +70,7 @@ pub async fn authenticate_by_name(
}
StatusCode::UNAUTHORIZED => anyhow::bail!("Wrong username or password."),
_ => {
println!("Sign in error: {:#?}", res);
error!("Sign in error: {:#?}", res);
anyhow::bail!("Error signing in.");
}
}

View File

@ -6,6 +6,7 @@ use relm4::{
gtk, Component, ComponentController, ComponentParts, ComponentSender, Controller,
SimpleComponent,
};
use tracing::warn;
use uuid::Uuid;
use crate::{
@ -125,7 +126,7 @@ impl SimpleComponent for LatestRow {
CollectionType::TvShows => tr!("library-section-title.latest-shows").to_string(),
CollectionType::Music => tr!("library-section-title.latest-music").to_string(),
s => {
println!("Unknown collection type: {s}");
warn!("Unknown collection type: {s}");
s.to_string()
}
};

View File

@ -7,6 +7,7 @@ use relm4::{
prelude::{AsyncComponent, AsyncComponentParts},
AsyncComponentSender,
};
use tracing::error;
use crate::{
app::{AppInput, APP_BROKER},
@ -298,8 +299,13 @@ async fn get_thumbnail(
.into_iter()
.collect();
let pixbuf = gdk_pixbuf::Pixbuf::from_read(img_bytes)
.unwrap_or_else(|_| panic!("Error creating media tile pixbuf: {:#?}", media.id));
let pixbuf = match gdk_pixbuf::Pixbuf::from_read(img_bytes) {
Ok(pixbuf) => pixbuf,
_ => {
error!("Error creating media tile pixbuf: {:#?}", media.id);
return None;
}
};
// TODO: merge resizing with how it's done for episode list

View File

@ -19,6 +19,7 @@ use relm4::{
ComponentController, RelmObjectExt, SharedState,
};
use std::sync::{Arc, RwLock};
use tracing::error;
use adw::prelude::*;
use gtk::glib;
@ -463,7 +464,7 @@ impl Library {
match api_client.ping().await {
Ok(_) => {}
Err(err) => {
println!("Error pinging server: {err}");
error!("Failed to ping server: {err}");
return LibraryCommandOutput::SetLibraryState(LibraryState::Offline);
}
}
@ -482,7 +483,7 @@ impl Library {
LibraryCommandOutput::LibraryLoaded(user_views.0, display_preferences)
}
Err(err) => {
println!("Error loading library: {err}");
error!("Failed to load library: {err}");
LibraryCommandOutput::SetLibraryState(LibraryState::Error)
}
}

View File

@ -4,6 +4,7 @@ use anyhow::Result;
use gtk::prelude::*;
use jellyfin_api::types::BaseItemDto;
use relm4::{adw::traits::ActionRowExt, gtk::traits::BoxExt, prelude::*};
use tracing::warn;
use crate::{
app::{AppInput, APP_BROKER},
@ -186,7 +187,7 @@ impl Component for SearchResultsEmpty {
{
Ok((items, _)) => SearchResultsEmptyCommandOutput::Suggestions(items),
Err(err) => {
println!("Error getting search suggestions: {err}");
warn!("Error getting search suggestions: {err}");
SearchResultsEmptyCommandOutput::Suggestions(vec![])
}
}

View File

@ -1,6 +1,7 @@
use fluent_templates::{lazy_static::lazy_static, FluentLoader};
use sys_locale::get_locale;
use tera::Tera;
use tracing::warn;
use unic_langid::{langid, LanguageIdentifier};
use crate::globals::CONFIG;
@ -17,7 +18,7 @@ lazy_static! {
pub static ref DEFAULT_LANGUAGE: LanguageIdentifier = get_locale()
.and_then(|l| l.parse().ok())
.unwrap_or_else(|| {
println!("Error parsing system locale, defaulting to en-US");
warn!("Error parsing system locale, defaulting to en-US");
langid!("en-US")
});
}

View File

@ -7,6 +7,7 @@ use std::{
};
use tokio::time::sleep;
use tracing::debug;
type DebounceCallback = Arc<Mutex<Box<dyn Fn() + Send>>>;
@ -44,7 +45,7 @@ impl Debounce {
if let Ok(callback) = callback.try_lock() {
callback();
} else {
println!("Debounce callback lock could not be acquired");
debug!("Debounce callback lock could not be acquired");
}
}
});

View File

@ -6,6 +6,7 @@ use std::{
use glib::SignalHandlerId;
use relm4::gtk::{self, glib, prelude::*};
use tracing::debug;
use uuid::Uuid;
use video_player_mpv::{Track, TrackType, VideoPlayerMpv};
@ -360,7 +361,7 @@ impl VideoPlayerBackend for VideoPlayerBackendMpv {
self.widget.disconnect(signal_handler_id);
}
None => {
println!("Signal handler not found when trying to disconnect: {id}");
debug!("Signal handler not found when trying to disconnect: {id}");
}
};
}

View File

@ -3,6 +3,7 @@ use std::mem::take;
use glib::SignalHandlerId;
use gtk::{glib, prelude::*};
use relm4::{gtk, ComponentParts, SimpleComponent};
use tracing::error;
use crate::{
tr,
@ -92,7 +93,7 @@ impl SimpleComponent for Fullscreen {
self.fullscreen = !self.fullscreen;
window.set_fullscreened(self.fullscreen);
} else {
println!("Error getting main window");
error!("Failed to get main window");
}
}
FullscreenInput::ExitFullscreen => {
@ -100,7 +101,7 @@ impl SimpleComponent for Fullscreen {
self.fullscreen = false;
window.set_fullscreened(false);
} else {
println!("Error getting main window");
error!("Failed to get main window");
}
}
FullscreenInput::WindowFullscreenChanged(fullscreen) => {

View File

@ -1,5 +1,6 @@
use bytes::Buf;
use std::{cell::RefCell, sync::Arc};
use tracing::warn;
use gdk::{Rectangle, Texture};
use graphene::Point;
@ -292,14 +293,14 @@ impl Scrubber {
let image = match thumbnails.get(nearest_thumbnail_idx) {
Some(thumbnail) => &thumbnail.image,
_ => {
println!("Error getting trickplay thumbnail");
warn!("Error getting trickplay thumbnail");
return None;
}
};
let pixbuf = match gdk_pixbuf::Pixbuf::from_read(image.clone().reader()) {
Ok(pixbuf) => pixbuf,
Err(err) => {
println!(
warn!(
"Error creating pixbuf for scrubber thumbnail at timestamp {timestamp}: {err}"
);
return None;

View File

@ -7,6 +7,7 @@ use relm4::{
gtk::{self, gio},
Component, ComponentParts, ComponentSender,
};
use tracing::warn;
use crate::{
jellyfin_api::api_client::ApiClient,
@ -243,7 +244,7 @@ impl Subtitles {
let playback_info = match api_client.get_playback_info(&item_id).await {
Ok(playback_info) => playback_info,
Err(err) => {
println!("Error getting playback info: {err}");
warn!("Error getting playback info: {err}");
return SubtitlesCommandOutput::ExternalSubtitlesLoaded(None);
}
};

View File

@ -20,7 +20,7 @@ use jellyfin_api::types::{BaseItemDto, BaseItemKind};
use relm4::component::{AsyncComponent, AsyncComponentController, AsyncController};
use relm4::{gtk, ComponentParts};
use relm4::{prelude::*, MessageBroker};
use tracing::{debug, info};
use tracing::{debug, info, warn};
use crate::app::{AppInput, APP_BROKER};
use crate::globals::CONFIG;
@ -722,7 +722,7 @@ impl VideoPlayer {
return VideoPlayerCommandOutput::LoadedTrickplay(None);
}
Err(err) => {
println!("Error fetching trickplay manifest: {err}");
warn!("Error fetching trickplay manifest: {err}");
return VideoPlayerCommandOutput::LoadedTrickplay(None);
}
};
@ -738,7 +738,7 @@ impl VideoPlayer {
return VideoPlayerCommandOutput::LoadedTrickplay(None);
}
Err(err) => {
println!("Error fetching trickplay thumbnails: {err}");
warn!("Error fetching trickplay thumbnails: {err}");
return VideoPlayerCommandOutput::LoadedTrickplay(None);
}
};

View File

@ -6,6 +6,7 @@ use std::{
},
};
use tracing::warn;
use uuid::Uuid;
use crate::{
@ -98,7 +99,7 @@ fn start_session_reporting(
.await)
.is_err()
{
println!("Error reporting playback progress.");
warn!("Error reporting playback progress.");
}
}
});
@ -133,7 +134,7 @@ fn start_session_reporting(
.await)
.is_err()
{
println!("Error reporting playback progress.");
warn!("Error reporting playback progress.");
}
}
});

View File

@ -6,6 +6,7 @@ use relm4::{
prelude::*,
AsyncComponentSender,
};
use tracing::warn;
use uuid::Uuid;
use crate::{
@ -121,7 +122,7 @@ impl AsyncComponent for SkipIntro {
self.intro_timestamps = match api_client.get_intro_timestamps(&id).await {
Ok(intro_timestamps) => intro_timestamps,
Err(err) => {
println!("Error getting intro timestamps for {id}: {err:#?}");
warn!("Error getting intro timestamps for {id}: {err:#?}");
None
}
};