Skip to content
Merged
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
25 changes: 2 additions & 23 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,15 @@
use std::path::{Path, PathBuf};

use clap::{
Command, CommandFactory, FromArgMatches, Parser, Subcommand, ValueEnum,
Command, CommandFactory, FromArgMatches, Parser, Subcommand,
builder::{
Styles,
styling::{AnsiColor, Effects},
},
};
use clap_complete::{Shell, aot::generate as generate_completions};

use crate::util::{BackgroundImageScale, BackgroundType, FontSlant, FontWeight, Rgba};

#[derive(Copy, Clone, Debug, ValueEnum)]
pub enum LogLevel {
Trace,
Debug,
Info,
Warn,
Error,
}

impl LogLevel {
pub fn to_level(self) -> tracing::Level {
match self {
Self::Trace => tracing::Level::TRACE,
Self::Debug => tracing::Level::DEBUG,
Self::Info => tracing::Level::INFO,
Self::Warn => tracing::Level::WARN,
Self::Error => tracing::Level::ERROR,
}
}
}
use crate::util::{BackgroundImageScale, BackgroundType, FontSlant, FontWeight, LogLevel, Rgba};

/// Customisable, minimalist screen locker for Wayland
#[derive(Parser, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn main() {

tracing_subscriber::fmt()
.with_timer(tracing_subscriber::fmt::time::uptime())
.with_max_level(args.log_level.to_level())
.with_max_level(args.log_level)
.init();

let now = chrono::Local::now();
Expand Down
21 changes: 21 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,27 @@ impl From<FontWeight> for cairo::FontWeight {
}
}

#[derive(Debug, Copy, Clone, ValueEnum)]
pub enum LogLevel {
Trace,
Debug,
Info,
Warn,
Error,
}

impl From<LogLevel> for tracing::level_filters::LevelFilter {
fn from(value: LogLevel) -> Self {
match value {
LogLevel::Trace => Self::TRACE,
LogLevel::Debug => Self::DEBUG,
LogLevel::Info => Self::INFO,
LogLevel::Warn => Self::WARN,
LogLevel::Error => Self::ERROR,
}
}
}

pub fn open_shm() -> Option<OwnedFd> {
let mut retries = 100;

Expand Down