mod file;
mod rotating;
mod sink;
mod toggle;
pub use self::file::{FileKeyLogSink, normalize_path};
pub use self::rotating::{
DEFAULT_PREFIX as ROTATING_DEFAULT_PREFIX, RotatingFileKeyLogSink, RotationPeriod,
};
pub use self::sink::{KeyLogSink, NoopKeyLogSink};
pub use self::toggle::{KeyLogToggle, ToggleableKeyLogSink};
use std::sync::Arc;
use rama_core::error::BoxError;
use super::KeyLogIntent;
pub fn open_intent_sink(intent: &KeyLogIntent) -> Result<Option<Arc<dyn KeyLogSink>>, BoxError> {
match intent {
KeyLogIntent::Disabled => Ok(None),
KeyLogIntent::Environment => {
Ok(FileKeyLogSink::try_from_env()?.map(|s| Arc::new(s) as Arc<dyn KeyLogSink>))
}
KeyLogIntent::File(path) => Ok(Some(
Arc::new(FileKeyLogSink::try_open(path)?) as Arc<dyn KeyLogSink>
)),
KeyLogIntent::Custom(sink) => Ok(Some(Arc::clone(sink))),
}
}