feat(otter): add log level cli config
This commit is contained in:
parent
5f57d85584
commit
5112a6ce35
3 changed files with 44 additions and 6 deletions
|
|
@ -11,6 +11,8 @@ use figment::{
|
|||
};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::config::LogLevel;
|
||||
|
||||
/// Otter is a lightweight implementation of the Gpodder API, designed to be used for small
|
||||
/// personal deployments.
|
||||
#[derive(Parser)]
|
||||
|
|
@ -28,21 +30,26 @@ pub struct ClapConfig {
|
|||
short,
|
||||
long = "config",
|
||||
env = "OTTER_CONFIG_FILE",
|
||||
value_name = "CONFIG_FILE"
|
||||
value_name = "CONFIG_FILE",
|
||||
global = true
|
||||
)]
|
||||
config_file: Option<PathBuf>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[arg(long = "data", value_name = "DATA_DIR")]
|
||||
#[arg(long = "data", value_name = "DATA_DIR", global = true)]
|
||||
data_dir: Option<PathBuf>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[arg(short, long, value_name = "DOMAIN")]
|
||||
#[arg(short, long, value_name = "DOMAIN", global = true)]
|
||||
domain: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[arg(short, long, value_name = "PORT")]
|
||||
#[arg(short, long, value_name = "PORT", global = true)]
|
||||
port: Option<u16>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[arg(short, long = "log", value_name = "LOG_LEVEL", global = true)]
|
||||
log_level: Option<LogLevel>,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
|
||||
use crate::server;
|
||||
|
||||
pub fn serve(config: &crate::config::Config) -> u8 {
|
||||
tracing_subscriber::fmt::init();
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(tracing::Level::from(config.log_level))
|
||||
.init();
|
||||
|
||||
tracing::info!("Initializing database and running migrations");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue