Skip to content

Commit

Permalink
[0.28] Introduce new features kv and json, and config option panic_if…
Browse files Browse the repository at this point in the history
…_error_channel_is_broken
  • Loading branch information
emabee committed Mar 16, 2024
1 parent d49c22e commit 57eb95a
Show file tree
Hide file tree
Showing 15 changed files with 527 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
},
"MD013": {
"line_length": 100,
"heading_line_length": 300
"heading_line_length": 300,
"code_block_line_length": 180
},
"MD033": {
"allowed_elements": [
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ 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.27.5-unpublished] - 2024-xx-xx
## [0.28.0] - 2024-03-16

Detach from `lazy_static`, use `std::sync::OnceLock` instead.

Bump minimal supported rust version to 1.70.

If `flexi_logger` runs into issues itself, it will try to write error messages into the configured
error output channel. By default, `flexi_logger` panics if writing to the error output channel fails.
It is now possible to gracefully "swallow" the error messages and continue
(see [panic_if_error_channel_is_broken](https://docs.rs/flexi_logger/latest/flexi_logger/struct.Logger.html#method.panic_if_error_channel_is_broken)).

The new feature `kv` allows making use of the `kv` feature of `log` together with `flexi_logger`s
format functions, and adds a dependency to `log/kv_serde`.

The new feature `json` adds a format function `json_format` and dependencies to `serde_json`,
`serde` and `serde_derive`.

## [0.27.4] - 2024-01-20

Add ability to omit the basename cleanly, without leading underscore
Expand Down
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flexi_logger"
version = "0.27.5-unpublished"
version = "0.28.0"
authors = ["emabee <meinolf.block@sap.com>"]
categories = ["development-tools::debugging"]
description = """
Expand Down Expand Up @@ -33,6 +33,8 @@ async = ["dep:crossbeam-channel", "dep:crossbeam-queue"]
colors = ["dep:nu-ansi-term", "is-terminal"]
compress = ["dep:flate2"]
dont_minimize_extra_stacks = []
json = ["dep:serde_json", "dep:serde", "dep:serde_derive"]
kv = ["log/kv_serde"]
specfile = ["specfile_without_notification", "dep:notify-debouncer-mini"]
specfile_without_notification = ["dep:serde", "dep:toml", "dep:serde_derive"]
syslog_writer = ["dep:libc", "dep:hostname"]
Expand All @@ -53,6 +55,7 @@ notify-debouncer-mini = { version = "0.3", optional = true, default-features = f
regex = { version = "1.1", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde_json = { version = "1.0", optional = true }
thiserror = "1.0"
toml = { version = "0.8", optional = true }
tracing = { version = "0.1.36", optional = true }
Expand Down
24 changes: 21 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.27"
flexi_logger = "0.28"
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.27", features = ["async", "specfile", "compress"] }
flexi_logger = { version = "0.28", 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.27", default_features = false }
flexi_logger = { version = "0.28", default_features = false }
log = "0.4"
```

Expand Down Expand Up @@ -127,6 +127,24 @@ For usecases where this is not desirable
(see [here](https://github.com/emabee/flexi_logger/issues/95) for some motivation),
you can activate this feature.

### **`json`**

Adds an additional format function `json_format` that prints the whole log line in json format,
like this:

```text
{"level":"WARN","timestamp":"2024-03-14 10:04:57.299908 +01:00","thread":"XY","module_path":"test_json","file":"src/test_json.rs","line":32,"text":"More foo than bar."}
```

Also adds a dependency to crate `json`.

### **`kv`**

If you use the `kv` feature of the `log` crate to enrich the log-macro calls with key-value pairs,
then you should also use the `kv` feature of `flexi_logger`
so that these key-value pairs are also written by the
provided [format functions](https://docs.rs/flexi_logger/latest/flexi_logger/#functions).

### **`specfile`**

Adds a method `Logger::start_with_specfile(specfile)`.
Expand Down
2 changes: 1 addition & 1 deletion scripts/qualify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ macro_rules! command {
}

fn run_script(s: &str) {
let mut path = std::path::PathBuf::from(std::env::var("CARGO_SCRIPT_BASE_PATH").unwrap());
let mut path = std::path::PathBuf::from("./scripts");
path.push(s);
let command = format!(
"cargo script {}",
Expand Down
Loading

0 comments on commit 57eb95a

Please sign in to comment.