fix: remove log (file) when level is explicitly set to OFF (#2083)

* fix level filter for OFF
* remove unwrap of file appender creation
This commit is contained in:
Luna Yao
2026-04-12 16:16:30 +02:00
committed by GitHub
parent 9e0a3b6936
commit 869e1b89f5
2 changed files with 44 additions and 46 deletions
@@ -1,4 +1,5 @@
use super::*;
use anyhow::anyhow;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct RollingConditionBase {
@@ -135,9 +136,11 @@ impl RollingFileAppenderBaseBuilder {
/// Builds a RollingFileAppenderBase instance from the current settings.
///
/// Returns an error if the filename is empty.
pub fn build(self) -> Result<RollingFileAppenderBase, &'static str> {
pub fn build(self) -> anyhow::Result<RollingFileAppenderBase> {
if self.filename.is_empty() {
return Err("A filename is required to be set and can not be blank");
return Err(anyhow!(
"A filename is required to be set and can not be blank"
));
}
Ok(RollingFileAppenderBase {
condition: self.condition,