Skip to content

Commit 57c5883

Browse files
author
8192K
committed
Improved documentation
1 parent 0cb42a0 commit 57c5883

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "redis_logger"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2018"
55
description = "A logger implementing the log::Log trait that writes log messages to a Redis pub/sub channel, a stream or both using the redis_rs crate"
66
repository = "https://github.com/8192K/redis_logger"

src/defaults.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
//! # Defaults Module
22
//!
33
//! This module provides default implementations for the `PubSubEncoder` and `StreamEncoder` traits.
4-
//!
5-
//! ## `DefaultPubSubEncoder`
6-
//!
7-
//! `DefaultPubSubEncoder` is a default implementation of the `PubSubEncoder` trait.
8-
//! It encodes a `log::Record` into a JSON object, where each field in the `Record` becomes a key-value pair in the JSON object.
9-
//! The JSON object is then converted into a byte vector.
10-
//!
11-
//! ## `DefaultStreamEncoder`
12-
//!
13-
//! `DefaultStreamEncoder` is a default implementation of the `StreamEncoder` trait.
14-
//! It encodes a `log::Record` into a vector of tuples, where each tuple contains a field name from the `Record` and the
15-
//! corresponding value as a byte vector. If a field in the `Record` is `None`, the byte vector is empty.
16-
//!
17-
//! ## Usage
18-
//!
19-
//! You can use these default encoders when you don't need to customize the encoding process.
20-
//! If you need to customize the encoding, you can implement the `PubSubEncoder` and `StreamEncoder` traits yourself.
214
225
use serializable_log_record::SerializableLogRecord;
236

247
use super::{PubSubEncoder, Record, StreamEncoder};
258

26-
/// Default implementation of the `PubSubEncoder` trait converting the incoming `log::Record` into a JSON object.
9+
/// `DefaultPubSubEncoder` is a default implementation of the `PubSubEncoder` trait.
10+
/// It encodes a `log::Record` into a JSON object, where each field in the `Record` becomes a key-value pair in the JSON object.
11+
/// The JSON object is then converted into a byte vector.
12+
///
13+
/// You can use these default encoders when you don't need to customize the encoding process.
14+
/// If you need to customize the encoding, you can implement the `PubSubEncoder` and `StreamEncoder` traits yourself.
2715
#[derive(Debug)]
2816
#[non_exhaustive]
2917
pub struct DefaultPubSubEncoder {}
@@ -41,7 +29,12 @@ impl PubSubEncoder for DefaultPubSubEncoder {
4129
}
4230
}
4331

44-
/// Default implementation of the `StreamEncoder` trait converting the incoming `log::Record` into a vector of tuples of field name and bytes.
32+
/// `DefaultStreamEncoder` is a default implementation of the `StreamEncoder` trait.
33+
/// It encodes a `log::Record` into a vector of tuples, where each tuple contains a field name from the `Record` and the
34+
/// corresponding value as a byte vector. If a field in the `Record` is `None`, the byte vector is empty.
35+
///
36+
/// You can use these default encoders when you don't need to customize the encoding process.
37+
/// If you need to customize the encoding, you can implement the `PubSubEncoder` and `StreamEncoder` traits yourself.
4538
#[derive(Debug)]
4639
#[non_exhaustive]
4740
pub struct DefaultStreamEncoder {}

0 commit comments

Comments
 (0)