improv: desktop entries update

This commit is contained in:
wiiznokes 2024-07-13 01:13:17 +02:00 • committed by GitHub
parent ab7a71a057
commit 172532056b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 559 additions and 663 deletions

View file

@ -1,19 +1,19 @@
[package]
name = "pop-launcher-bin"
version = "1.2.3"
edition = "2018"
license = "GPL-3.0-only"
edition.workspace = true
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
pop-launcher-toolkit = { path = "../toolkit" }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["std", "fmt", "env-filter"] }
dirs = "5.0.1"
tracing.workspace = true
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["std", "fmt", "env-filter", "chrono"] }
dirs.workspace = true
mimalloc = "0.1.39"
[dependencies.tokio]
version = "1.37.0"
workspace = true
features = ["rt"]

View file

@ -5,6 +5,8 @@ use pop_launcher_toolkit::plugins;
use pop_launcher_toolkit::service;
use mimalloc::MiMalloc;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::EnvFilter;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
@ -37,7 +39,10 @@ async fn main() {
}
}
// todo: support journald once this issue is resolved: https://github.com/tokio-rs/tracing/issues/2348
fn init_logging(cmd: &str) {
use tracing_subscriber::{fmt, Registry};
let logdir = match dirs::state_dir() {
Some(dir) => dir.join("pop-launcher/"),
None => dirs::home_dir()
@ -49,15 +54,27 @@ fn init_logging(cmd: &str) {
let logfile = std::fs::OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.append(true)
.open(logdir.join([cmd, ".log"].concat().as_str()).as_path());
if let Ok(file) = logfile {
use tracing_subscriber::{fmt, EnvFilter};
fmt()
.with_env_filter(EnvFilter::from_default_env())
.with_writer(file)
.init();
if let Ok(meta) = file.metadata() {
if meta.len() > 1000 {
let _ = file.set_len(0);
}
}
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("warn"))
.unwrap();
let fmt_layer = fmt::layer()
.with_target(false)
.with_timer(fmt::time::ChronoLocal::new("%T".into()))
.with_writer(file);
let subscriber = Registry::default().with(filter_layer).with(fmt_layer);
tracing::subscriber::set_global_default(subscriber).expect("Failed to set subscriber");
}
}