Skip to content

Commit

Permalink
[0.24.3] Fix some issues
Browse files Browse the repository at this point in the history
- fix #132
- fix #133
- Improve documentation of feature dependencies
  • Loading branch information
emabee committed Feb 3, 2023
1 parent e012c68 commit 52883c8
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 24 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,24 @@ 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.24.2] - unpublished
## [0.25.0] - 2023-02-03

Fix issues #132 and #133.

Update dependencies.

Bump MSRV to 1.60, because toml needs it now.

Improve documentation of feature dependencies.

Minor stuff.

## [0.24.2] - 2022-12-15

Move from unmaintained `ansi_term` to `nu-ansi-term`.

Fix new clippies.

## [0.24.1] - 2022-11-01

Some improvements in respect to `use_utc`:
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flexi_logger"
version = "0.24.2"
version = "0.25.0"
authors = ["emabee <meinolf.block@sap.com>"]
categories = ["development-tools::debugging"]
description = """
Expand All @@ -15,7 +15,7 @@ keywords = ["file", "logger"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/emabee/flexi_logger"
rust-version = "1.59.0"
rust-version = "1.60.0"

[lib]
doctest = false
Expand Down Expand Up @@ -55,7 +55,7 @@ regex = {version = "1.1", optional = true}
serde = {version = "1.0", optional = true}
serde_derive = {version = "1.0", optional = true}
thiserror = "1.0"
toml = {version = "0.5", optional = true }
toml = {version = "0.7", optional = true }
tracing-subscriber = {version = "0.3", optional = true, features = ["env-filter"]}
tracing = {version = "0.1.36", optional = true}

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and you use the ```log``` macros to write log lines from your code):

```toml
[dependencies]
flexi_logger = "0.24"
flexi_logger = "0.25"
log = "0.4"
```

Expand Down Expand Up @@ -68,15 +68,15 @@ Make use of the non-default features by specifying them in your `Cargo.toml`, e.

```toml
[dependencies]
flexi_logger = { version = "0.24", features = ["async", "specfile", "compress"] }
flexi_logger = { version = "0.25", features = ["async", "specfile", "compress"] }
log = "0.4"
```

or, to get the smallest footprint (and no colors), switch off even the default features:

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

Expand Down
6 changes: 3 additions & 3 deletions scripts/qualify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ fn main() {

// Build in important variants
std::fs::remove_file("Cargo.lock").ok();
run_command!("cargo", "+1.59.0", "build", "--no-default-features");
run_command!("cargo", "+1.59.0", "build", "--all-features");
run_command!("cargo", "+1.60.0", "build", "--no-default-features");
run_command!("cargo", "+1.60.0", "build", "--all-features");

std::fs::remove_file("Cargo.lock").ok();
run_command!("cargo", "build");
Expand All @@ -65,7 +65,7 @@ fn main() {
run_command!("cargo", "+nightly", "clippy", "--all-targets", "--all-features", "--", "-D", "warnings");

// Run tests in important variants
run_command!("cargo", "+1.59.0", "test", "--all-features");
run_command!("cargo", "+1.60.0", "test", "--all-features");
run_command!("cargo", "test", "--release", "--all-features");
run_command!("cargo", "test", "--no-default-features");
run_command!("cargo", "test", "--release");
Expand Down
26 changes: 14 additions & 12 deletions src/deferred_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ impl<'a> DeferredNow {
}
}

// The format described in RFC 3339; example: 1985-04-12T23:20:50.523Z
#[cfg(feature = "syslog_writer")]
pub(crate) fn format_rfc3339(&mut self) -> DelayedFormat<StrftimeItems<'_>> {
self.format("%Y-%m-%dT%H:%M:%S%.3fZ")
/// Produces a preformatted object suitable for printing.
///
/// The format described in RFC 3339 is used. Example: 1985-04-12T23:20:50.523Z
pub fn format_rfc3339(&mut self) -> DelayedFormat<StrftimeItems<'_>> {
self.format("%Y-%m-%dT%H:%M:%S%.3f%Z")
}

// format_rfc3164: Mmm dd hh:mm:ss, where
Expand Down Expand Up @@ -172,13 +173,14 @@ mod test {
fn test_format_rfc3339() {
// The format described in RFC 3339; example: 1985-04-12T23:20:50.52Z
let s = super::DeferredNow::new().format_rfc3339().to_string();
let bytes = s.into_bytes();
assert_eq!(bytes[4], b'-');
assert_eq!(bytes[7], b'-');
assert_eq!(bytes[10], b'T');
assert_eq!(bytes[13], b':');
assert_eq!(bytes[16], b':');
assert_eq!(bytes[19], b'.');
assert_eq!(bytes[23], b'Z');
let bytes = s.clone().into_bytes();
assert_eq!(bytes[4], b'-', "s = {s}");
assert_eq!(bytes[7], b'-', "s = {s}");
assert_eq!(bytes[10], b'T', "s = {s}");
assert_eq!(bytes[13], b':', "s = {s}");
assert_eq!(bytes[16], b':', "s = {s}");
assert_eq!(bytes[19], b'.', "s = {s}");
assert_eq!(bytes[23], b'+', "s = {s}");
assert_eq!(bytes[26], b':', "s = {s}");
}
}
5 changes: 5 additions & 0 deletions src/flexi_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,25 @@ pub enum FlexiLoggerError {
/// Filesystem notifications for the specfile could not be set up.
#[error("Filesystem notifications for the specfile or the log file could not be set up")]
#[cfg(feature = "notify")]
#[cfg_attr(docsrs, doc(cfg(feature = "notify")))]
Notify(#[from] notify::Error),

/// Parsing the configured logspec toml-file failed.
#[error("Parsing the configured logspec toml-file failed")]
#[cfg(feature = "specfile_without_notification")]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
SpecfileToml(#[from] toml::de::Error),

/// Specfile cannot be accessed or created.
#[error("Specfile cannot be accessed or created")]
#[cfg(feature = "specfile_without_notification")]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
SpecfileIo(std::io::Error),

/// Specfile has an unsupported extension.
#[error("Specfile has an unsupported extension")]
#[cfg(feature = "specfile_without_notification")]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
SpecfileExtension(&'static str),

/// Invalid level filter.
Expand Down Expand Up @@ -85,6 +89,7 @@ pub enum FlexiLoggerError {

///
#[cfg(feature = "trc")]
#[cfg_attr(docsrs, doc(cfg(feature = "trc")))]
#[error("Tracing initialization failed")]
TracingSetup(#[from] tracing::subscriber::SetGlobalDefaultError),
}
Expand Down
3 changes: 3 additions & 0 deletions src/log_specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ impl LogSpecification {
///
/// [`FlexiLoggerError::Parse`] if the input is malformed.
#[cfg(feature = "specfile_without_notification")]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
pub fn from_toml<S: AsRef<str>>(s: S) -> Result<Self, FlexiLoggerError> {
#[derive(Clone, Debug, serde_derive::Deserialize)]
struct LogSpecFileFormat {
Expand Down Expand Up @@ -307,6 +308,7 @@ impl LogSpecification {
///
/// [`FlexiLoggerError::SpecfileIo`] if writing fails.
#[cfg(feature = "specfile_without_notification")]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
pub fn to_toml(&self, w: &mut dyn std::io::Write) -> Result<(), FlexiLoggerError> {
self.to_toml_impl(w).map_err(FlexiLoggerError::SpecfileIo)
}
Expand Down Expand Up @@ -609,6 +611,7 @@ impl LogSpecBuilder {
///
/// This method is only avaible if the dafault feature `textfilter` is not switched off.
#[cfg(feature = "textfilter")]
#[cfg_attr(docsrs, doc(cfg(feature = "textfilter")))]
#[must_use]
pub fn build_with_textfilter(&self, tf: Option<Regex>) -> LogSpecification {
LogSpecification {
Expand Down
3 changes: 2 additions & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ impl Logger {
/// # Errors
///
/// Several variants of [`FlexiLoggerError`] can occur.
#[cfg_attr(docsrs, doc(cfg(feature = "specfile_without_notification")))]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
#[cfg(feature = "specfile_without_notification")]
pub fn start_with_specfile<P: AsRef<Path>>(
self,
Expand All @@ -822,6 +822,7 @@ impl Logger {
/// # Errors
///
/// Several variants of [`FlexiLoggerError`] can occur.
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
#[cfg(feature = "specfile_without_notification")]
pub fn build_with_specfile<P: AsRef<Path>>(
self,
Expand Down
1 change: 1 addition & 0 deletions src/logger_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ impl Drop for WritersHandle {

/// Trait that allows to register for changes to the log specification.
#[cfg(feature = "specfile_without_notification")]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
pub trait LogSpecSubscriber: 'static + Send {
/// Apply a new `LogSpecification`.
///
Expand Down
1 change: 1 addition & 0 deletions src/trc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ use tracing_subscriber::{EnvFilter, FmtSubscriber};
///
/// Several variants of [`FlexiLoggerError`] can occur.
#[cfg(feature = "specfile_without_notification")]
#[cfg_attr(docsrs, doc(cfg(feature = "specfile")))]
pub fn subscribe_to_specfile<P: AsRef<Path>>(
specfile: P,
reloader: Box<dyn Fn(LogSpecification) + Send + Sync>,
Expand Down
2 changes: 2 additions & 0 deletions src/write_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ pub const DEFAULT_FLUSH_INTERVAL: Duration = Duration::from_secs(1);
/// Default size of the message pool;
/// a higher value could further reduce allocations during log file rotation and cleanup.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub const DEFAULT_POOL_CAPA: usize = 50;

/// Default capacity for the message buffers;
/// a higher value reduces allocations when longer log lines are used.
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub const DEFAULT_MESSAGE_CAPA: usize = 200;

/// Describes whether the log output should be written synchronously or asynchronously,
Expand Down
2 changes: 2 additions & 0 deletions src/writers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ pub(crate) mod file_log_writer;
mod log_writer;

#[cfg(feature = "syslog_writer")]
#[cfg_attr(docsrs, doc(cfg(feature = "syslog_writer")))]
mod syslog_writer;

#[cfg(feature = "syslog_writer")]
#[cfg_attr(docsrs, doc(cfg(feature = "syslog_writer")))]
pub use self::syslog_writer::{
LevelToSyslogSeverity, Syslog, SyslogFacility, SyslogSeverity, SyslogWriter,
};
Expand Down
2 changes: 1 addition & 1 deletion src/writers/file_log_writer/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ pub(crate) fn remove_or_compress_too_old_logfiles_impl(
for (index, file) in list_of_log_and_compressed_files(file_spec).enumerate() {
if index >= log_limit + compress_limit {
// delete (log or log.gz)
std::fs::remove_file(&file)?;
std::fs::remove_file(file)?;
} else if index >= log_limit {
#[cfg(feature = "compress")]
{
Expand Down

0 comments on commit 52883c8

Please sign in to comment.