[go: up one dir, main page]

ftail 0.3.1

Ftail is simple logging implementation for the `log` crate with support for multiple channels.
Documentation
use std::{fmt::Display, path::PathBuf};

use log::SetLoggerError;

#[derive(Debug)]
pub enum FtailError {
    SetLoggerError(SetLoggerError),
    NoChannelsError,
    IoError(std::io::Error),
    PermissionsError(PathBuf),
}

impl std::error::Error for FtailError {}

impl Display for FtailError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            FtailError::SetLoggerError(e) => write!(f, "Error setting logger: {}", e),
            FtailError::NoChannelsError => write!(f, "No channels were added to the logger"),
            FtailError::IoError(e) => write!(f, "I/O error: {}", e),
            FtailError::PermissionsError(path) => {
                write!(f, "The path {} is read-only", path.display())
            }
        }
    }
}