Skip to main content

create_log_file

Function create_log_file 

Source
pub fn create_log_file(file_path: &str) -> Result<File>
Expand description

Creates and initialises a log file for the static site generator.

Establishes a new log file at the specified path with appropriate permissions and write capabilities. The log file is used to track the generation process and any errors that occur.

§Arguments

  • file_path - The desired location for the log file

§Returns

  • Ok(File) - A file handle for the created log file
  • Err - If the file cannot be created or permissions are insufficient

§Examples

use ssg::create_log_file;

fn main() -> anyhow::Result<()> {
    let log_file = create_log_file("./site_generation.log")?;
    println!("Log file created successfully");
    Ok(())
}

§Errors

Returns an error if:

  • The specified path is invalid
  • File creation permissions are insufficient
  • The parent directory is not writable