Skip to content

Commit 12ec0e6

Browse files
committed
Rename PartialFormatter to OptFormatter
1 parent ba27645 commit 12ec0e6

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

spdlog/src/formatter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mod full_formatter;
5555
#[cfg(feature = "serde_json")]
5656
mod json_formatter;
5757
mod local_time_cacher;
58-
mod partial_formatter;
58+
mod opt_formatter;
5959
mod pattern_formatter;
6060
mod unreachable_formatter;
6161

@@ -66,7 +66,7 @@ pub use full_formatter::*;
6666
#[cfg(feature = "serde_json")]
6767
pub use json_formatter::*;
6868
pub(crate) use local_time_cacher::*;
69-
pub use partial_formatter::*;
69+
pub use opt_formatter::*;
7070
pub use pattern_formatter::*;
7171
pub(crate) use unreachable_formatter::*;
7272

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ use crate::{
55
Error, Record, StringBuf, __EOL,
66
};
77

8+
///
89
#[derive(Clone)]
9-
pub struct PartialFormatter {
10+
pub struct OptFormatter {
1011
options: FormattingOptions,
1112
}
1213

13-
impl PartialFormatter {
14+
impl OptFormatter {
1415
#[must_use]
15-
pub fn builder() -> PartialFormatterBuilder {
16-
PartialFormatterBuilder(FormattingOptions {
16+
pub fn builder() -> OptFormatterBuilder {
17+
OptFormatterBuilder(FormattingOptions {
1718
time: true,
1819
logger_name: true,
1920
level: true,
@@ -100,7 +101,7 @@ impl PartialFormatter {
100101
}
101102
}
102103

103-
impl Formatter for PartialFormatter {
104+
impl Formatter for OptFormatter {
104105
fn format(
105106
&self,
106107
record: &Record,
@@ -112,9 +113,9 @@ impl Formatter for PartialFormatter {
112113
}
113114
}
114115

115-
pub struct PartialFormatterBuilder(FormattingOptions);
116+
pub struct OptFormatterBuilder(FormattingOptions);
116117

117-
impl PartialFormatterBuilder {
118+
impl OptFormatterBuilder {
118119
#[must_use]
119120
pub fn time(&mut self, value: bool) -> &mut Self {
120121
self.0.time = value;
@@ -151,10 +152,10 @@ impl PartialFormatterBuilder {
151152
self
152153
}
153154

154-
/// Builds a `PartialFormatter`.
155+
/// Builds a `OptFormatter`.
155156
#[must_use]
156-
pub fn build(&mut self) -> PartialFormatter {
157-
PartialFormatter {
157+
pub fn build(&mut self) -> OptFormatter {
158+
OptFormatter {
158159
options: self.0.clone(),
159160
}
160161
}
@@ -246,10 +247,10 @@ mod tests {
246247
fn default_should_same_with_full() {
247248
let record = record();
248249

249-
let partial = {
250+
let opt = {
250251
let mut buf = StringBuf::new();
251252
let mut ctx = FormatterContext::new();
252-
PartialFormatter::builder()
253+
OptFormatter::builder()
253254
.build()
254255
.format(&record.as_ref(), &mut buf, &mut ctx)
255256
.unwrap();
@@ -264,16 +265,16 @@ mod tests {
264265
(buf, ctx)
265266
};
266267

267-
assert_eq!(partial.0, full.0);
268-
assert_eq!(partial.1.style_range(), full.1.style_range());
268+
assert_eq!(opt.0, full.0);
269+
assert_eq!(opt.1.style_range(), full.1.style_range());
269270
}
270271

271272
#[test]
272273
fn no_time() {
273274
let record = record();
274275
let mut buf = StringBuf::new();
275276
let mut ctx = FormatterContext::new();
276-
PartialFormatter::builder()
277+
OptFormatter::builder()
277278
.time(false)
278279
.build()
279280
.format(&record.as_ref(), &mut buf, &mut ctx)
@@ -291,7 +292,7 @@ mod tests {
291292
let record = record();
292293
let mut buf = StringBuf::new();
293294
let mut ctx = FormatterContext::new();
294-
PartialFormatter::builder()
295+
OptFormatter::builder()
295296
.time(false)
296297
.logger_name(false)
297298
.build()
@@ -310,7 +311,7 @@ mod tests {
310311
let record = record();
311312
let mut buf = StringBuf::new();
312313
let mut ctx = FormatterContext::new();
313-
PartialFormatter::builder()
314+
OptFormatter::builder()
314315
.time(false)
315316
.logger_name(false)
316317
.level(false)
@@ -327,7 +328,7 @@ mod tests {
327328
let record = record();
328329
let mut buf = StringBuf::new();
329330
let mut ctx = FormatterContext::new();
330-
PartialFormatter::builder()
331+
OptFormatter::builder()
331332
.time(false)
332333
.logger_name(false)
333334
.level(false)
@@ -345,7 +346,7 @@ mod tests {
345346
let record = record();
346347
let mut buf = StringBuf::new();
347348
let mut ctx = FormatterContext::new();
348-
PartialFormatter::builder()
349+
OptFormatter::builder()
349350
.time(false)
350351
.eol(false)
351352
.build()

spdlog/src/sink/android_sink.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{ffi::CString, io, ptr::null, result::Result as StdResult};
33
use libc::EPERM;
44

55
use crate::{
6-
formatter::{Formatter, FormatterContext, PartialFormatter},
6+
formatter::{Formatter, FormatterContext, OptFormatter},
77
prelude::*,
88
sink::{GetSinkProp, Sink, SinkProp},
99
sync::*,
@@ -141,8 +141,8 @@ impl AndroidSinkBuilder {
141141

142142
/// Specifies a formatter.
143143
///
144-
/// This parameter is **optional**, and defaults to [`PartialFormatter`]
145-
/// `(!time !level !eol)`.
144+
/// This parameter is **optional**, and defaults to [`OptFormatter`] `(!time
145+
/// !level !eol)`.
146146
#[must_use]
147147
pub fn formatter<F>(self, formatter: F) -> Self
148148
where
@@ -192,13 +192,13 @@ impl AndroidSink {
192192

193193
/// Gets a builder of `AndroidSink` with default parameters:
194194
///
195-
/// | Parameter | Default Value |
196-
/// |-----------------|--------------------------------------------|
197-
/// | [level_filter] | [`LevelFilter::All`] |
198-
/// | [formatter] | [`PartialFormatter`] `(!time !level !eol)` |
199-
/// | [error_handler] | [`ErrorHandler::default()`] |
200-
/// | | |
201-
/// | [tag] | [`AndroidLogTag::Default`] |
195+
/// | Parameter | Default Value |
196+
/// |-----------------|----------------------------------------|
197+
/// | [level_filter] | [`LevelFilter::All`] |
198+
/// | [formatter] | [`OptFormatter`] `(!time !level !eol)` |
199+
/// | [error_handler] | [`ErrorHandler::default()`] |
200+
/// | | |
201+
/// | [tag] | [`AndroidLogTag::Default`] |
202202
///
203203
/// [level_filter]: AndroidSinkBuilder::level_filter
204204
/// [formatter]: AndroidSinkBuilder::formatter
@@ -208,7 +208,7 @@ impl AndroidSink {
208208
pub fn builder() -> AndroidSinkBuilder {
209209
let prop = SinkProp::default();
210210
prop.set_formatter(
211-
PartialFormatter::builder()
211+
OptFormatter::builder()
212212
.time(false)
213213
.level(false)
214214
.eol(false)

spdlog/src/sink/journald_sink.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{io, os::raw::c_int};
22

33
use crate::{
4-
formatter::{Formatter, FormatterContext, PartialFormatter},
4+
formatter::{Formatter, FormatterContext, OptFormatter},
55
sink::{GetSinkProp, Sink, SinkProp},
66
sync::*,
77
Error, ErrorHandler, Level, LevelFilter, Record, Result, StdResult, StringBuf,
@@ -97,11 +97,11 @@ impl JournaldSink {
9797

9898
/// Gets a builder of `JournaldSink` with default parameters:
9999
///
100-
/// | Parameter | Default Value |
101-
/// |-----------------|-------------------------------------------------|
102-
/// | [level_filter] | [`LevelFilter::All`] |
103-
/// | [formatter] | [`PartialFormatter`] `(!time !source_location)` |
104-
/// | [error_handler] | [`ErrorHandler::default()`] |
100+
/// | Parameter | Default Value |
101+
/// |-----------------|---------------------------------------------|
102+
/// | [level_filter] | [`LevelFilter::All`] |
103+
/// | [formatter] | [`OptFormatter`] `(!time !source_location)` |
104+
/// | [error_handler] | [`ErrorHandler::default()`] |
105105
///
106106
/// [level_filter]: JournaldSinkBuilder::level_filter
107107
/// [formatter]: JournaldSinkBuilder::formatter
@@ -110,7 +110,7 @@ impl JournaldSink {
110110
pub fn builder() -> JournaldSinkBuilder {
111111
let prop = SinkProp::default();
112112
prop.set_formatter(
113-
PartialFormatter::builder()
113+
OptFormatter::builder()
114114
.time(false)
115115
.source_location(false)
116116
.build(),
@@ -179,8 +179,8 @@ impl JournaldSinkBuilder {
179179

180180
/// Specifies a formatter.
181181
///
182-
/// This parameter is **optional**, and defaults to [`PartialFormatter`]
183-
/// `(!time !source_location)`.
182+
/// This parameter is **optional**, and defaults to [`OptFormatter`] `(!time
183+
/// !source_location)`.
184184
#[must_use]
185185
pub fn formatter<F>(self, formatter: F) -> Self
186186
where

0 commit comments

Comments
 (0)