pub fn setup_logger(logger_config: LoggerConfig) -> Result<(), LoggerSetupError>Expand description
Sets up and configures the application’s global logger using the fern crate.
This function initializes a global logger that dispatches messages to both standard output (the console) and a specified log file. It performs several validation checks on the provided log file path before attempting to create the file and apply the logging configuration.
Log messages are formatted to include a high-precision timestamp, log level,
and the source module (target). The default logging level is set to Debug.
§Arguments
logger_config- ALoggerConfigstruct containing the path to the log file.
§Returns
An empty Result (Ok(())) on successful initialization of the logger.
§Errors
Returns a LoggerSetupError variant if any validation or setup step fails:
LoggerSetupError::EmptyLogFileName: If the configured log file name is empty or contains only whitespace.LoggerSetupError::PathIsADirectory: If the provided log file path points to an existing directory.LoggerSetupError::MissingFileName: If the log file path does not have a valid file name component (e.g., it ends in..).LoggerSetupError::ParentDirDoesNotExist: If the parent directory of the specified log file does not exist.LoggerSetupError::ParentIsNotADirectory: If a component of the log file’s parent path is a file, not a directory.LoggerSetupError::CouldNotOpenOutputFile: If the log file cannot be opened or created, which typically indicates a file system permissions issue.