trying to use tokio for async stuff and tracing for logging
This commit is contained in:
parent
7681f1c811
commit
bef09ed805
2 changed files with 42 additions and 8 deletions
|
@ -1,7 +1,13 @@
|
|||
use time::macros::format_description;
|
||||
use tracing_subscriber::{
|
||||
fmt::{self, time::LocalTime},
|
||||
EnvFilter,
|
||||
};
|
||||
|
||||
mod db {
|
||||
use diesel::{Connection, SqliteConnection};
|
||||
use dirs::data_local_dir;
|
||||
use sqlx::{Error, SqliteConnection as SqlxConn};
|
||||
use sqlx::{Connection as SqlxConnection, Error};
|
||||
|
||||
pub enum Model {
|
||||
Songs,
|
||||
|
@ -23,18 +29,43 @@ mod db {
|
|||
})
|
||||
}
|
||||
|
||||
// async fn get_items(model: Model) -> Result<(), Error> {
|
||||
// let conn = SqlxConn::connect(
|
||||
// "/home/chris/.local/share/lumina/library-db.sqlite3",
|
||||
// fn get_items(model: Model) -> Result<(), Error> {
|
||||
// let conn = sqlx::SqliteConnection::connect(
|
||||
// "sqlite::/home/chris/.local/share/lumina/library-db.sqlite3",
|
||||
// );
|
||||
// match model {
|
||||
// Songs => {
|
||||
// let select = sqlx::query_as("SELECT $1")
|
||||
// .bind("songs")
|
||||
// .fetch_all(&mut conn).await?;
|
||||
// .fetch_all(&mut conn);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Ok(());
|
||||
// Ok(())
|
||||
// }
|
||||
}
|
||||
|
||||
#[cxx_qt::bridge]
|
||||
mod utilities {
|
||||
|
||||
#[cxx_qt::qobject]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct Utils {}
|
||||
|
||||
impl qobject::Utils {
|
||||
#[qinvokable]
|
||||
pub fn setup(&self) {
|
||||
crate::utils::setup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup() {
|
||||
tracing_subscriber::FmtSubscriber::builder()
|
||||
.pretty()
|
||||
.with_line_number(true)
|
||||
.with_level(true)
|
||||
.with_target(true)
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ mod ytdl {
|
|||
println!("{:?}", data_dir);
|
||||
self.as_mut().set_loading(true);
|
||||
let thread = self.qt_thread();
|
||||
thread::spawn(move || {
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
runtime.spawn(async move {
|
||||
let url = url.to_string();
|
||||
let output_dirs = data_dir.to_str().unwrap();
|
||||
println!("{output_dirs}");
|
||||
|
@ -93,5 +94,7 @@ mod ytdl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn dl_video() {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue