Skip to content

Commit

Permalink
[0.16.0] Fix wrong wording and wrong suffix for compressed log files …
Browse files Browse the repository at this point in the history
…(see issue 65)

- deprecate the feature name `ziplog` and call the feature now `compress`
- rename `Cleanup::KeepZipFiles` into `Cleanup::KeepCompressedFiles`
   and `Cleanup::KeepLogAndZipFiles` into `Cleanup::KeepLogAndCompressedFiles`
   - the old names still work but are deprecated
- change the file suffix for the compressed log files from `.zip` to `.gz`
  • Loading branch information
emabee committed Sep 19, 2020
1 parent ed23959 commit c321bbf
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 79 deletions.
50 changes: 35 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,32 @@ 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.15.13] - 2020-08-07
## [0.16.0] - 2020-09-19

If file logging is used, do not create the output file if no log is written.
Solves [issue-62](https://github.com/emabee/flexi_logger/issues/62).

Improve color handling

- introduce AdaptiveFormat for a clearer API
- Support using feature `atty` without provided coloring
- Extend example `colors` to provide insight in how AdaptiveFormat works
- Remove the deprecated method `Logger::do_not_log()`; use `log_target()` with `LogTarget::DevNull` instead.
- Remove deprecated method `Logger::o_log_to_file()`; use `log_target()` instead. The clearer convenience method `Logger::log_to_file()` is still available.

Improve the compression feature. Solves [issue-65](https://github.com/emabee/flexi_logger/issues/65).

- breaking change: change the file suffix for the compressed log files from `.zip` to `.gz`
- Fix wrong wording in code and documentation
- deprecate the feature name `ziplog` and call the feature now `compress`
- rename `Cleanup::KeepZipFiles` into `Cleanup::KeepCompressedFiles`
and `Cleanup::KeepLogAndZipFiles` into `Cleanup::KeepLogAndCompressedFiles`
- the old names still work but are deprecated

If file logging is used, do not create the output file if no log is written
Solves issue [issue-62](https://github.com/emabee/flexi_logger/issues/62).

## [0.15.12] - 2020-08-07
## [0.15.12] - 2020-28-08

Make `1.37.0` the minimal rust version for `flexi_logger`.

Expand Down Expand Up @@ -264,8 +284,8 @@ When file rotation is used, the name of the file to which the logs are written i

Details:

* the logs are always written to a file with infix _rCURRENT
* if this file exceeds the specified rotate-over-size, it is closed and renamed
- the logs are always written to a file with infix _rCURRENT
- if this file exceeds the specified rotate-over-size, it is closed and renamed
to a file with a sequential number infix, and then the logging continues again
to the (fresh) file with infix _rCURRENT

Expand Down Expand Up @@ -356,10 +376,10 @@ in the auto-generated docu (because it does not use --allfeatures)

Add specfile feature

* Add a feature that allows to specify the LogSpecification via a file
- Add a feature that allows to specify the LogSpecification via a file
that can be edited while the program is running
* Remove/hide deprecated APIs
* As a consequence, cleanup code, get rid of duplicate stuff.
_ Remove/hide deprecated APIs
- As a consequence, cleanup code, get rid of duplicate stuff.

## [0.7.1] - 2018-03-07

Expand All @@ -370,11 +390,11 @@ Update docu and the description in cargo.toml

Add support for multiple log output streams

* replace FlexiWriter with DefaultLogWriter, which wraps a FileLogWriter
* add test where a SecurityWriter and an AlertWriter are added
* add docu
* move deprecated structs to separate package
* move benches to folder benches
- replace FlexiWriter with DefaultLogWriter, which wraps a FileLogWriter
- add test where a SecurityWriter and an AlertWriter are added
- add docu
- move deprecated structs to separate package
- move benches to folder benches

## [0.6.13] 2018-02-09

Expand All @@ -398,6 +418,6 @@ Publish version based on log 0.4

Use builder pattern for LogSpecification and Logger

* deprecate outdated API
* "objectify" LogSpecification
* improve documentation, e.g. document the dash/underscore issue
- deprecate outdated API
- "objectify" LogSpecification
- improve documentation, e.g. document the dash/underscore issue
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flexi_logger"
version = "0.16.0-alpha"
version = "0.16.0"
authors = ["emabee <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
Expand All @@ -25,7 +25,8 @@ colors = ["atty", "lazy_static","yansi"]
specfile = ["specfile_without_notification","notify"]
specfile_without_notification = ["serde","toml","serde_derive"]
syslog_writer = ["libc", "hostname"]
ziplogs = ["flate2"]
ziplog = ["compress"] # for backwards compatibility
compress = ["flate2"]
textfilter = ["regex"]

[dependencies]
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ Add flexi_logger to the dependencies section in your project's `Cargo.toml`, wit

```toml
[dependencies]
flexi_logger = "0.15"
flexi_logger = "0.16"
log = "0.4"
```

or, if you want to use some of the optional features, with something like

```toml
[dependencies]
flexi_logger = { version = "0.15", features = ["specfile", "ziplogs"] }
flexi_logger = { version = "0.16", features = ["specfile", "compress"] }
log = "0.4"
```

or, to get the smallest footprint (and no colors), with

```toml
[dependencies]
flexi_logger = { version = "0.15", default_features = false }
flexi_logger = { version = "0.16", default_features = false }
log = "0.4"
```

Expand Down Expand Up @@ -146,14 +146,22 @@ The default feature `colors` simplifies this by doing three things:
* provides additional colored pendants to the existing uncolored format functions
* it uses `colored_default_format()` for the output to stderr,
and the non-colored `default_format()` for the output to files
* it activates the optional dependency to `atty` to being able to switch off
* it activates the optional dependency to `atty` to being able to switch off
coloring if the output is not sent to a terminal but e.g. piped to another program.

**<span style="color:red">C</span><span style="color:blue">o</span><span style="color:green">l</span><span style="color:orange">o</span><span style="color:magenta">r</span><span style="color:darkturquoise">s</span>**,
or styles in general, are a matter of taste, and no choice will fit every need. So you can override the default formatting and coloring in various ways.

With `--no-default-features --features="atty"` you can remove the yansi-based coloring but keep the capability to switch off your own coloring.

### **`compress`**

The `compress` feature adds two options to the `Logger::Cleanup` `enum`, which allow keeping some
or all rotated log files in compressed form (`.gz`) rather than as plain text files.

The feature was previously called `ziplogs`. The old name still works, but is deprecated and
should be replaced.

### **`specfile`**

The `specfile` feature adds a method `Logger::start_with_specfile(specfile)`.
Expand All @@ -176,11 +184,6 @@ For that reason the feature is not active by default.
Pretty much like `specfile`, except that updates to the file are being ignored.
See [issue-59](https://github.com/emabee/flexi_logger/issues/59) for more details.

### **`ziplogs`**

The `ziplogs` feature adds two options to the `Logger::Cleanup` `enum`, which allow keeping some
or all rotated log files in zipped form rather than as text files.

### **`textfilter`**

Removes the ability to filter logs by text, but also removes the dependency on the regex crate.
Expand Down
1 change: 1 addition & 0 deletions scripts/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fn main() {
"./*logspec.toml",
"./log_files/**/*.log",
"./log_files/**/*.zip",
"./log_files/**/*.gz",
"./test_spec/*.toml",
] {
for globresult in glob::glob(pattern).unwrap() {
Expand Down
4 changes: 2 additions & 2 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ impl Logger {
}

/// When rotation is used with some `Cleanup` variant, then this option defines
/// if the cleanup activities (finding files, deleting files, evtl zipping files) is done in
/// the current thread (in the current log-call), or whether cleanup is delegated to a
/// if the cleanup activities (finding files, deleting files, evtl compressing files) is done
/// in the current thread (in the current log-call), or whether cleanup is delegated to a
/// background thread.
///
/// As of `flexi_logger` version `0.14.7`,
Expand Down
28 changes: 18 additions & 10 deletions src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,38 @@ pub enum Naming {
/// See
/// [`Logger::cleanup_in_background_thread`](struct.Logger.html#method.cleanup_in_background_thread)
/// if you want to control whether this extra thread is created and used.
#[allow(deprecated)]
#[derive(Copy, Clone, Debug)]
pub enum Cleanup {
/// Older log files are not touched - they remain for ever.
Never,
/// The specified number of rotated log files are kept.
/// Older files are deleted, if necessary.
KeepLogFiles(usize),
/// The specified number of rotated log files are zipped and kept.
/// The specified number of rotated log files are compressed and kept.
/// Older files are deleted, if necessary.
///
/// This option is only available with feature `ziplogs`.
#[cfg(feature = "ziplogs")]
/// This option is only available with feature `compress`.
#[cfg(feature = "compress")]
KeepCompressedFiles(usize),
/// Outdated
#[cfg(feature = "compress")]
#[deprecated(since = "0.16.0", note = "use KeepCompressedFiles instead")]
KeepZipFiles(usize),
/// Allows keeping some files as text files and some as zip files.
///
/// Is used in
/// Allows keeping some files as text files and some as compressed files.
///
/// ## Example
///
/// `KeepLogAndZipFiles(5,30)` ensures that the youngest five log files are kept as text files,
/// the next 30 are kept as zip files, and older files are removed.
/// `KeepLogAndCompressedFiles(5,30)` ensures that the youngest five log files are
/// kept as text files, the next 30 are kept as compressed files with additional suffix `.gz`,
/// and older files are removed.
///
/// This option is only available with feature `ziplogs`.
#[cfg(feature = "ziplogs")]
/// This option is only available with feature `compress`.
#[cfg(feature = "compress")]
KeepLogAndCompressedFiles(usize, usize),
/// Outdated
#[deprecated(since = "0.16.0", note = "use KeepLogAndCompressedFiles instead")]
#[cfg(feature = "compress")]
KeepLogAndZipFiles(usize, usize),
}

Expand Down
4 changes: 2 additions & 2 deletions src/reconfiguration_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ impl ReconfigurationHandle {
///
/// This method is supposed to be called at the very end of your program, in case you use
/// your own writers, or if you want to securely shutdown the cleanup-thread of the
/// `FileLogWriter`. If you use a [`Cleanup`](enum.Cleanup.html) strategy with zipping,
/// `FileLogWriter`. If you use a [`Cleanup`](enum.Cleanup.html) strategy with compressing,
/// and your process terminates
/// without correctly shutting down the cleanup-thread, then you might stop the cleanup-thread
/// while it is zipping a log file, which can leave unexpected files in the filesystem.
/// while it is compressing a log file, which can leave unexpected files in the filesystem.
///
/// See also [`LogWriter::shutdown`](writers/trait.LogWriter.html#method.shutdown).
pub fn shutdown(&self) {
Expand Down
4 changes: 2 additions & 2 deletions src/writers/file_log_writer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ impl FileLogWriterBuilder {
}

/// When rotation is used with some `Cleanup` variant, then this option defines
/// if the cleanup activities (finding files, deleting files, evtl zipping files) is done in
/// the current thread (in the current log-call), or whether cleanup is delegated to a
/// if the cleanup activities (finding files, deleting files, evtl compressing files) is done
/// in the current thread (in the current log-call), or whether cleanup is delegated to a
/// background thread.
///
/// As of `flexi_logger` version `0.14.7`,
Expand Down
Loading

0 comments on commit c321bbf

Please sign in to comment.