feat: hack get in control of log level
I haven't found a good way of enabling all of mine, but disabling all of theirs. as such right now it is a deny list, where some entries reqwest,cliff,hyper is set to error, and our own is controlled via. Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
f75e839759
commit
b4acb55d0c
@ -10,7 +10,7 @@ cuddle-please-misc = { path = "crates/cuddle-please-misc" }
|
|||||||
|
|
||||||
anyhow = { version = "1.0.72" }
|
anyhow = { version = "1.0.72" }
|
||||||
tracing = { version = "0.1", features = ["log"] }
|
tracing = { version = "0.1", features = ["log"] }
|
||||||
tracing-subscriber = { version = "0.3.17" }
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
|
||||||
clap = { version = "4.3.19", features = ["derive", "env"] }
|
clap = { version = "4.3.19", features = ["derive", "env"] }
|
||||||
dotenv = { version = "0.15.0" }
|
dotenv = { version = "0.15.0" }
|
||||||
url = { version = "2.4.0" }
|
url = { version = "2.4.0" }
|
||||||
|
@ -11,6 +11,8 @@ use cuddle_please_misc::{
|
|||||||
ConsoleUi, DynRemoteGitClient, DynUi, GiteaClient, GlobalArgs, LocalGitClient, StdinFn,
|
ConsoleUi, DynRemoteGitClient, DynUi, GiteaClient, GlobalArgs, LocalGitClient, StdinFn,
|
||||||
VcsClient,
|
VcsClient,
|
||||||
};
|
};
|
||||||
|
use tracing::Level;
|
||||||
|
use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, EnvFilter};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config_command::{ConfigCommand, ConfigCommandHandler},
|
config_command::{ConfigCommand, ConfigCommandHandler},
|
||||||
@ -92,6 +94,22 @@ impl Command {
|
|||||||
let git_client = self.get_git(&config)?;
|
let git_client = self.get_git(&config)?;
|
||||||
let gitea_client = self.get_gitea_client(&config);
|
let gitea_client = self.get_gitea_client(&config);
|
||||||
|
|
||||||
|
let filter = match self.global.log_level {
|
||||||
|
cuddle_please_misc::LogLevel::None => None,
|
||||||
|
cuddle_please_misc::LogLevel::Trace => Some(Level::TRACE),
|
||||||
|
cuddle_please_misc::LogLevel::Debug => Some(Level::DEBUG),
|
||||||
|
cuddle_please_misc::LogLevel::Info => Some(Level::INFO),
|
||||||
|
cuddle_please_misc::LogLevel::Error => Some(Level::ERROR),
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(filter) = filter {
|
||||||
|
let env_filter = EnvFilter::builder().with_regex(false).parse(format!(
|
||||||
|
"{},hyper=error,reqwest=error,git_cliff_core=error",
|
||||||
|
filter
|
||||||
|
))?;
|
||||||
|
tracing_subscriber::fmt().with_env_filter(env_filter).init();
|
||||||
|
}
|
||||||
|
|
||||||
match &self.commands {
|
match &self.commands {
|
||||||
Some(Commands::Release {}) => {
|
Some(Commands::Release {}) => {
|
||||||
ReleaseCommandHandler::new(self.ui, config, git_client, gitea_client)
|
ReleaseCommandHandler::new(self.ui, config, git_client, gitea_client)
|
||||||
|
@ -52,6 +52,15 @@ config-stdin will consume stdin until the channel is closed via. EOF"
|
|||||||
default_value = "gitea"
|
default_value = "gitea"
|
||||||
)]
|
)]
|
||||||
pub engine: RemoteEngine,
|
pub engine: RemoteEngine,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
env = "CUDDLE_PLEASE_LOG_LEVEL",
|
||||||
|
long,
|
||||||
|
global = true,
|
||||||
|
help_heading = "Global",
|
||||||
|
default_value = "none"
|
||||||
|
)]
|
||||||
|
pub log_level: LogLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ValueEnum, Clone, Debug)]
|
#[derive(ValueEnum, Clone, Debug)]
|
||||||
@ -59,3 +68,11 @@ pub enum RemoteEngine {
|
|||||||
Local,
|
Local,
|
||||||
Gitea,
|
Gitea,
|
||||||
}
|
}
|
||||||
|
#[derive(ValueEnum, Clone, Debug)]
|
||||||
|
pub enum LogLevel {
|
||||||
|
None,
|
||||||
|
Trace,
|
||||||
|
Debug,
|
||||||
|
Info,
|
||||||
|
Error,
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@ mod local_git_client;
|
|||||||
mod ui;
|
mod ui;
|
||||||
mod versioning;
|
mod versioning;
|
||||||
|
|
||||||
pub use args::{GlobalArgs, RemoteEngine, StdinFn};
|
pub use args::{GlobalArgs, LogLevel, RemoteEngine, StdinFn};
|
||||||
pub use cliff::{changelog_parser, ChangeLogBuilder};
|
pub use cliff::{changelog_parser, ChangeLogBuilder};
|
||||||
pub use git_client::VcsClient;
|
pub use git_client::VcsClient;
|
||||||
pub use gitea_client::{Commit, DynRemoteGitClient, GiteaClient, RemoteGitEngine, Tag};
|
pub use gitea_client::{Commit, DynRemoteGitClient, GiteaClient, RemoteGitEngine, Tag};
|
||||||
|
@ -2,7 +2,6 @@ use cuddle_please_commands::PleaseCommand;
|
|||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
tracing_subscriber::fmt::init();
|
|
||||||
|
|
||||||
let current_dir = std::env::current_dir().ok();
|
let current_dir = std::env::current_dir().ok();
|
||||||
let current_dir = current_dir.as_deref();
|
let current_dir = current_dir.as_deref();
|
||||||
|
Loading…
Reference in New Issue
Block a user