Add --verbose flag
This commit is contained in:
parent
f9533d8119
commit
2f7234189b
3 changed files with 16 additions and 5 deletions
|
|
@ -14,6 +14,9 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `--verbose` flag
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Respect colon-delimited emoji when calculating nick hue
|
- Respect colon-delimited emoji when calculating nick hue
|
||||||
- Display colon-delimited emoji in nicks and messages
|
- Display colon-delimited emoji in nicks and messages
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::vec;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use crossterm::style::{ContentStyle, Stylize};
|
use crossterm::style::{ContentStyle, Stylize};
|
||||||
use log::{Level, Log};
|
use log::{Level, LevelFilter, Log};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
@ -212,7 +212,7 @@ impl Log for Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Logger {
|
impl Logger {
|
||||||
pub fn init(level: Level) -> (Self, LoggerGuard, mpsc::UnboundedReceiver<()>) {
|
pub fn init(verbose: bool) -> (Self, LoggerGuard, mpsc::UnboundedReceiver<()>) {
|
||||||
let (event_tx, event_rx) = mpsc::unbounded_channel();
|
let (event_tx, event_rx) = mpsc::unbounded_channel();
|
||||||
let logger = Self {
|
let logger = Self {
|
||||||
event_tx,
|
event_tx,
|
||||||
|
|
@ -222,8 +222,13 @@ impl Logger {
|
||||||
messages: logger.messages.clone(),
|
messages: logger.messages.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
log::set_max_level(if verbose {
|
||||||
|
LevelFilter::Debug
|
||||||
|
} else {
|
||||||
|
LevelFilter::Info
|
||||||
|
});
|
||||||
|
|
||||||
log::set_boxed_logger(Box::new(logger.clone())).expect("logger already set");
|
log::set_boxed_logger(Box::new(logger.clone())).expect("logger already set");
|
||||||
log::set_max_level(level.to_level_filter());
|
|
||||||
|
|
||||||
(logger, guard, event_rx)
|
(logger, guard, event_rx)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ impl Default for Command {
|
||||||
#[derive(Debug, clap::Parser)]
|
#[derive(Debug, clap::Parser)]
|
||||||
#[command(version)]
|
#[command(version)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
/// Show more detailed log messages.
|
||||||
|
#[arg(long, short)]
|
||||||
|
verbose: bool,
|
||||||
|
|
||||||
/// Path to the config file.
|
/// Path to the config file.
|
||||||
///
|
///
|
||||||
/// Relative paths are interpreted relative to the current directory.
|
/// Relative paths are interpreted relative to the current directory.
|
||||||
|
|
@ -114,9 +118,8 @@ fn set_offline(config: &mut Config, args_offline: bool) {
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
let (logger, logger_guard, logger_rx) = Logger::init(log::Level::Debug);
|
|
||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
let (logger, logger_guard, logger_rx) = Logger::init(args.verbose);
|
||||||
let dirs = ProjectDirs::from("de", "plugh", "cove").expect("unable to determine directories");
|
let dirs = ProjectDirs::from("de", "plugh", "cove").expect("unable to determine directories");
|
||||||
|
|
||||||
let config_path = args
|
let config_path = args
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue