Skip to content

Commit

Permalink
target: fix compile on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
chensoft committed Jan 24, 2024
1 parent 6d45510 commit 086c77f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/define.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Log levels and Encode trait
pub(crate) use std::io::Write;
pub(crate) use std::path::Path;
pub(crate) use std::borrow::Cow;
pub(crate) use std::cell::RefCell;
pub(crate) use indexmap::IndexMap;
Expand Down
6 changes: 4 additions & 2 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ impl Target for StderrTarget {
///
/// ```
/// fn main() -> anyhow::Result<()> {
/// let mut sample = std::env::temp_dir();
/// sample.push("sample.log");
/// let mut logger = logkit::Logger::new();
/// logger.route("default", Box::new(logkit::FileTarget::new("/tmp/sample.log")?));
/// logger.route("default", Box::new(logkit::FileTarget::new(sample)?));
/// Ok(())
/// }
/// ```
Expand All @@ -53,7 +55,7 @@ pub struct FileTarget {
}

impl FileTarget {
pub fn new(path: &str) -> anyhow::Result<Self> {
pub fn new(path: impl AsRef<Path>) -> anyhow::Result<Self> {
Ok(Self {file: ReentrantMutex::new(RefCell::new(std::fs::OpenOptions::new().create(true).append(true).open(path)?))})
}
}
Expand Down

0 comments on commit 086c77f

Please sign in to comment.