From 3fc8ede609beb787aee8199b06a40ac9742aa116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=82=8E=E6=B3=BC?= Date: Wed, 2 Aug 2023 15:21:48 +0800 Subject: [PATCH] Feature: add feature flag "tracing-log" to emit log record for tracing event --- Cargo.toml | 2 +- openraft/Cargo.toml | 5 +++++ openraft/src/docs/feature_flags/feature-flags.md | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8761b5995..be63a939d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ serde_json = "1.0.57" tempfile = { version = "3.4.0" } thiserror = "1.0.33" tokio = { version="1.8", default-features=false, features=["fs", "io-util", "macros", "rt", "rt-multi-thread", "sync", "time"] } -tracing = "0.1.29" +tracing = { version = "0.1.29" } tracing-appender = "0.2.0" tracing-futures = "0.2.4" tracing-subscriber = { version = "0.3.3", features=["env-filter"] } diff --git a/openraft/Cargo.toml b/openraft/Cargo.toml index e91f17b69..bc281a3fb 100644 --- a/openraft/Cargo.toml +++ b/openraft/Cargo.toml @@ -93,6 +93,11 @@ singlethreaded = ["macros/singlethreaded"] # For instance, in an even number nodes cluster, erasing a node's data and then rebooting it(log reverts to empty) will not result in data loss. loosen-follower-log-revert = [] +# Enables "log" feature in `tracing` crate, to let tracing events emit log +# record. +# See: https://docs.rs/tracing/latest/tracing/#emitting-log-records +tracing-log = [ "tracing/log" ] + # default = ["single-term-leader"] [package.metadata.docs.rs] diff --git a/openraft/src/docs/feature_flags/feature-flags.md b/openraft/src/docs/feature_flags/feature-flags.md index 4c2f0b08c..9ab45c970 100644 --- a/openraft/src/docs/feature_flags/feature-flags.md +++ b/openraft/src/docs/feature_flags/feature-flags.md @@ -37,9 +37,13 @@ By default openraft enables no features. This feature disables `Adapter`, which is for v1 storage to be used as v2. V2 storage separates log store and state machine store so that log IO and state machine IO can be parallelized naturally.

- + - `singlethreaded`: removes `Send` bounds from `AppData`, `AppDataResponse`, `RaftEntry`, and `SnapshotData` to force the asynchronous runtime to spawn any tasks in the current thread. This is for any single-threaded application that never allows a raft instance to be shared among multiple threads. In order to use the feature, `AsyncRuntime::spawn` should invoke `tokio::task::spawn_local` or equivalents.

+ +- `tracing-log`: enables "log" feature in `tracing` crate, to let tracing events + emit log record. + See: [tracing doc: emitting-log-records](https://docs.rs/tracing/latest/tracing/#emitting-log-records)