Trait astral::thirdparty::slog::Value

pub trait Value {
    fn serialize(
        &self,
        record: &Record<'_>,
        key: &'static str,
        serializer: &mut dyn Serializer
    ) -> Result<(), Error>; }
Expand description

Value that can be serialized

Types that implement this type implement custom serialization in the structured part of the log macros. Without an implementation of Value for your type you must emit using either the ? “debug”, #? “pretty-debug”, % “display”, #% “alternate display” or SerdeValue (if you have the nested-values feature enabled) formatters.

Example

use slog::{Key, Value, Record, Result, Serializer};
struct MyNewType(i64);

impl Value for MyNewType {
    fn serialize(&self, _rec: &Record, key: Key, serializer: &mut Serializer) -> Result {
        serializer.emit_i64(key, self.0)
    }
}

See also KV for formatting both the key and value.

Required Methods

Serialize self into Serializer

Structs implementing this trait should generally only call respective methods of serializer.

Implementations on Foreign Types

Implementors