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

Last update to 0.29.1 breaks file naming #178

Closed
jb-alvarado opened this issue Oct 4, 2024 · 1 comment
Closed

Last update to 0.29.1 breaks file naming #178

jb-alvarado opened this issue Oct 4, 2024 · 1 comment

Comments

@jb-alvarado
Copy link
Contributor

Hello, I use this code to implement a file logger:

impl MultiFileLogger {
    pub fn new(log_path: PathBuf) -> Self {
        MultiFileLogger {
            log_path,
            writers: Arc::new(Mutex::new(HashMap::new())),
        }
    }

    fn get_writer(&self, channel: i32) -> io::Result<Arc<Mutex<FileLogWriter>>> {
        let mut writers = self.writers.lock().unwrap();
        if let hash_map::Entry::Vacant(e) = writers.entry(channel) {
            let writer = FileLogWriter::builder(
                FileSpec::default()
                    .suppress_timestamp()
                    .directory(&self.log_path)
                    .basename("ffplayout")
                    .discriminant(channel.to_string()),
            )
            .format(file_formatter)
            .append()
            .rotate(
                Criterion::Age(Age::Day),
                Naming::TimestampsCustomFormat {
                    current_infix: Some(""),
                    format: "%Y-%m-%d",
                },
                Cleanup::KeepLogFiles(ARGS.log_backup_count.unwrap_or(14)),
            )
            .try_build()
            .map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?;
            e.insert(Arc::new(Mutex::new(writer)));
        }

        Ok(writers.get(&channel).unwrap().clone())
    }
}

In flexi_logger 0.29.0 it gives me a current log file: ffplayout_1.log and rotated ones: ffplayout_1_2024-10-03.log.

In version 0.29.1, the current log file is generated in the format: ffplayout_1_.log, which breaks my program. I would kindly like to ask if it would be possible for you to fix this issue.

@emabee
Copy link
Owner

emabee commented Oct 6, 2024

Sure!

@emabee emabee closed this as completed in b4c434e Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants