Skip to content

Commit

Permalink
[0.11.2] Change API to more idiomatic parameter types, in a compatibl…
Browse files Browse the repository at this point in the history
…e way

- Logger::directory() and o_directory(), and
  Logger::create_symlink() and o_create_symlink(): take Into<PathBuf> rather than Into<String>
- same for the respective methods of FileLogWriter
- implement SyslogWriter (not yet exposed, since hardly tested)
  • Loading branch information
emabee committed Mar 22, 2019
1 parent 2757e79 commit 9932c08
Show file tree
Hide file tree
Showing 11 changed files with 469 additions and 115 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ todo
tests/logspec.toml
*~
.*~
.vscode
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.11.2] - 2019-03-22

Change API to more idiomatic parameter types, in a compatible way.

Add first implementation of a SyslogWriter.

## [0.11.1] - 2019-03-06

Add option to write windows line endings, rather than a plain `\n`.
Expand Down
16 changes: 11 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flexi_logger"
version = "0.11.1"
version = "0.11.2"
authors = ["emabee <[email protected]>"]
edition = "2018"
license = "MIT/Apache-2.0"
Expand All @@ -22,19 +22,25 @@ all-features = true
[features]
default = []
specfile = ["serde","toml","notify", "serde_derive"]
syslog_writer = ["libc", "hostname", "procinfo"]
ziplogs = ["zip"]

[dependencies]
chrono = "0.4"
glob = "0.2"
regex = "1.0"
glob = "0.3"
hostname = {version = "0.1", optional = true}
log = { version = "0.4", features = ["std"] }
serde = { version = "1.0", optional = true }
toml = { version = "0.4", optional = true }
notify = { version = "4.0", optional = true }
regex = "1.1"
serde = { version = "1.0", optional = true }
serde_derive = {version = "1.0", optional = true}
toml = { version = "0.4", optional = true }
zip = {version = "0.5", optional = true}

[target.'cfg(unix)'.dependencies]
libc = {version = "^0.2.50", optional = true}
procinfo = {version = "0.4", optional = true}

[dev-dependencies]
serde_derive = "1.0"
version-sync = "0.7"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Add flexi_logger to the dependencies section in your project's `Cargo.toml`, wit

```toml
[dependencies]
flexi_logger = "^0.11.1"
flexi_logger = "^0.11.2"
log = "0.4"
```

or, if you want to use the optional features, with

```toml
[dependencies]
flexi_logger = { version = "^0.11.1", features = ["specfile", "ziplogs"] }
flexi_logger = { version = "^0.11.2", features = ["specfile", "ziplogs"] }
log = "0.4"
```

Expand Down
2 changes: 1 addition & 1 deletion benches/bench_reconfigurable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn b20_initialize_logger(_: &mut Bencher) {
Logger::with_str("info")
.log_to_file()
.directory("log_files")
.start_reconfigurable()
.start()
.unwrap_or_else(|e| panic!("Logger initialization failed with {}", e));
}

Expand Down
14 changes: 8 additions & 6 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use std::collections::HashMap;
#[cfg(feature = "specfile")]
use std::path::Path;
use std::path::PathBuf;
#[cfg(feature = "specfile")]
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
Expand Down Expand Up @@ -353,7 +354,7 @@ impl Logger {
/// This parameter only has an effect if `log_to_file()` is used, too.
/// If the specified folder does not exist, the initialization will fail.
/// By default, the log files are created in the folder where the program was started.
pub fn directory<S: Into<String>>(mut self, directory: S) -> Logger {
pub fn directory<S: Into<PathBuf>>(mut self, directory: S) -> Logger {
self.flwb = self.flwb.directory(directory);
self
}
Expand Down Expand Up @@ -440,11 +441,12 @@ impl Logger {
self
}

/// The specified String will be used on linux systems to create in the current folder
/// a symbolic link to the current log file.
/// The specified path will be used on linux systems to create a symbolic link
/// to the current log file.
///
/// This method has no effect on filesystems where symlinks are not supported.
/// This option only has an effect if `log_to_file()` is used, too.
pub fn create_symlink<S: Into<String>>(mut self, symlink: S) -> Logger {
pub fn create_symlink<P: Into<PathBuf>>(mut self, symlink: P) -> Logger {
self.flwb = self.flwb.create_symlink(symlink);
self
}
Expand Down Expand Up @@ -517,7 +519,7 @@ impl Logger {
/// This parameter only has an effect if `log_to_file` is set to true.
/// If the specified folder does not exist, the initialization will fail.
/// With None, the log files are created in the folder where the program was started.
pub fn o_directory<S: Into<String>>(mut self, directory: Option<S>) -> Logger {
pub fn o_directory<P: Into<PathBuf>>(mut self, directory: Option<P>) -> Logger {
self.flwb = self.flwb.o_directory(directory);
self
}
Expand Down Expand Up @@ -590,7 +592,7 @@ impl Logger {
///
/// If a String is specified, it will be used on linux systems to create in the current folder
/// a symbolic link with this name to the current log file.
pub fn o_create_symlink<S: Into<String>>(mut self, symlink: Option<S>) -> Logger {
pub fn o_create_symlink<P: Into<PathBuf>>(mut self, symlink: Option<P>) -> Logger {
self.flwb = self.flwb.o_create_symlink(symlink);
self
}
Expand Down
Loading

0 comments on commit 9932c08

Please sign in to comment.