Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ secret-service = { version = "5.1.0", features = [
], optional = true }
thiserror = { version = "2.0", optional = true }
secstr = { version = "0.5", optional = true }
tracing-journald = { version = "0.3.2" }
tracing-subscriber = { version = "0.3.22", features = [
"env-filter",
"tracing-log",
] }

[dependencies.cosmic-files]
git = "https://github.com/pop-os/cosmic-files.git"
Expand Down
26 changes: 26 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ use std::{
sync::{LazyLock, Mutex, atomic::Ordering},
};
use tokio::sync::mpsc;
use tracing_journald as journald;
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::{EnvFilter, fmt};

use config::{
AppTheme, CONFIG_VERSION, ColorScheme, ColorSchemeId, ColorSchemeKind, Config, Profile,
Expand Down Expand Up @@ -92,6 +97,27 @@ pub fn icon_cache_get(name: &'static str, size: u16) -> widget::icon::Icon {
/// Runs application with these settings
#[rustfmt::skip]
fn main() -> Result<(), Box<dyn Error>> {
let filter = EnvFilter::builder()
.with_default_directive(LevelFilter::WARN.into())
.from_env_lossy();

let fmt_layer = fmt::layer().compact();

match journald::layer() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to check if this is portable - what happens when trying to compile this on a non-systemd or non-linux OS?

Ok(journald_layer) => tracing_subscriber::registry()
.with(fmt_layer)
.with(journald_layer)
.with(filter)
.init(),
Err(_) => {
tracing_subscriber::registry()
.with(fmt_layer)
.with(filter)
.init();
log::warn!("Failed to init journald logging.");
}
};

let raw_args = RawArgs::from_args();
let mut cursor = raw_args.cursor();

Expand Down