Skip to content

Commit 92f8ff1

Browse files
committed
feat: slog - add ability to store nested values
#[derive(Debug, Clone, Serialize, SerdeValue)] struct Item {...} let inner = Item {...} info!(root, "Info breadcrumb"; "nested" => Item);
1 parent 8999079 commit 92f8ff1

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ with_log = ["log", "with_backtrace"]
3030
with_debug_to_log = ["log"]
3131
with_env_logger = ["with_log", "env_logger"]
3232
with_slog = ["slog", "serde_json"]
33+
with_slog_nested = ["with_slog", "slog/nested-values"]
3334
with_error_chain = ["error-chain", "with_backtrace"]
3435
with_device_info = ["libc", "hostname", "uname", "with_client_implementation"]
3536
with_rust_info = ["rustc_version", "with_client_implementation"]

src/integrations/slog.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ impl Serializer for StoringSerializer {
119119
// impl_number!(u128 => emit_u128);
120120
// impl_number!(i128 => emit_i128);
121121

122+
#[allow(missing_docs)]
123+
#[cfg(feature = "with_slog_nested")]
124+
fn emit_serde(&mut self, key: slog::Key, value: &dyn slog::SerdeValue) -> slog::Result {
125+
self.emit_serde_json_value(key, serde_json::json!(value.as_serde()))
126+
}
127+
122128
#[allow(missing_docs)]
123129
fn emit_arguments(&mut self, _: slog::Key, _: &fmt::Arguments) -> slog::Result {
124130
Ok(())

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
//! is currently the default transport.
110110
//! * `with_curl_transport`: enables the curl transport.
111111
//! * `with_slog`: enables the `slog` integration
112+
//! * `with_slog_nested`: enables the `slog` integration with ability to store nested structures
112113
#![warn(missing_docs)]
113114

114115
#[macro_use]

0 commit comments

Comments
 (0)