diff --git a/Cargo.toml b/Cargo.toml index 5271601..bc973ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ hdrhistogram = "6" slog-async = "2" smallvec = "0.6" num = "0.1" +dirs = "1" sloggers = { path = "../sloggers" } diff --git a/src/hist.rs b/src/hist.rs index 27fa422..f34bff7 100644 --- a/src/hist.rs +++ b/src/hist.rs @@ -4,8 +4,9 @@ use std::time::{Instant, Duration, SystemTime, UNIX_EPOCH}; use std::path::PathBuf; use std::thread::{self, JoinHandle}; use std::io; -use std::{mem, fs, env}; +use std::{mem, fs}; +use dirs::home_dir; use hdrhistogram::{Histogram}; use hdrhistogram::serialization::V2DeflateSerializer; use hdrhistogram::serialization::interval_log::{IntervalLogWriterBuilder, Tag}; @@ -51,7 +52,7 @@ impl Clone for HistLog { impl HistLog { pub fn new(series: &'static str, tag: &'static str, freq: Duration) -> Self { let (tx, rx) = channel(); - let mut dir = env::home_dir().unwrap(); + let mut dir = home_dir().expect("home_dir"); dir.push("src/market-maker/var/hist"); fs::create_dir_all(&dir).unwrap(); let thread = Some(Arc::new(Self::scribe(series, rx, dir))); diff --git a/src/lib.rs b/src/lib.rs index 35fc687..8279c55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,7 @@ extern crate uuid; extern crate hdrhistogram; extern crate smallvec; extern crate num; +extern crate dirs; #[cfg(feature = "zmq")] extern crate zmq;