Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #29 from runabove/logdir
Browse files Browse the repository at this point in the history
feat: make log dir if missing
  • Loading branch information
d33d33 authored May 24, 2017
2 parents df506f4 + 7d1c785 commit b81333a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "beamium"
version = "1.5.0"
version = "1.5.1"
authors = [ "d33d33 <kevin.georges@corp.ovh.com>" ]

build = "build.rs"
Expand Down
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::fs;
use nix::sys::signal;
use std::time::Duration;
use std::path::Path;

mod config;
mod scraper;
Expand Down Expand Up @@ -76,6 +77,18 @@ fn main() {
let config = config.ok().unwrap();

// Setup logging
let log_path = Path::new(&config.parameters.log_file).parent();
if log_path.is_some() {
let log_path = log_path.unwrap();
info!(format!("{}", log_path.display()));
let dir = fs::create_dir_all(&log_path);
if dir.is_err() {
crit!("Fail to create log directory {}: {}",
log_path.display(),
dir.err().unwrap());
std::process::exit(-1);
}
}
log::log(&config.parameters, matches.occurrences_of("v"));

// Ensure dirs
Expand Down

0 comments on commit b81333a

Please sign in to comment.