Skip to content

Commit

Permalink
refactor: return error when creating logger directory
Browse files Browse the repository at this point in the history
  • Loading branch information
enigbe committed Nov 7, 2024
1 parent 8c55876 commit c13e8de
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ impl FilesystemLogger {
/// Creates a new filesystem logger given the path to the log file and the log level.
pub(crate) fn new(log_file_path: String, level: Level) -> Result<Self, ()> {
if let Some(parent_dir) = Path::new(&log_file_path).parent() {
fs::create_dir_all(parent_dir).expect("Failed to create log parent directory");
fs::create_dir_all(parent_dir)
.map_err(|e| eprintln!("ERROR: Failed to create log parent directory: {}", e))?;

// make sure the file exists.
fs::OpenOptions::new()
Expand Down

0 comments on commit c13e8de

Please sign in to comment.