Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not create empty logs directory when not in verbose mode #2057

Merged
merged 1 commit into from
Jun 10, 2024
Merged
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
9 changes: 6 additions & 3 deletions frb_codegen/src/library/utils/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ use log::LevelFilter;
/// configure_opinionated_logging("./logs/", false).expect("failed to initialize log");
/// ```
pub fn configure_opinionated_logging(path: &str, verbose: bool) -> Result<(), fern::InitError> {
std::fs::create_dir_all(path).unwrap();
let level_filter = log_level_from_env_var().unwrap_or_else(|| verbose_to_level_filter(verbose));

if level_filter == LevelFilter::Debug {
std::fs::create_dir_all(path).unwrap();
}

let mut fern_logger = fern::Dispatch::new();
fern_logger = log_format_simple(fern_logger);
fern_logger = match log_level_from_env_var().unwrap_or_else(|| verbose_to_level_filter(verbose))
{
fern_logger = match level_filter {
LevelFilter::Debug => fern_logger
.level(LevelFilter::Debug)
.chain(fern::DateBased::new(path, "%Y-%m-%d.log"))
Expand Down
Loading