Struct logging_rs::Formatter
source · pub struct Formatter {
pub color_format_string: String,
pub format_string: String,
pub timestamp_format: String,
}
Expand description
Logging formatter object.
Use Formatter::new()
to create formatter objects instead of using this struct.
Parameters
color_format_string
: Format string supporting special ASCII control charactersformat_string
: Format string NOT supporting special ASCII control characterstimestamp_format
: Timestamp format string in strftime format
Returns
A new Formatter
object with the specified format strings.
Examples
logging_rs::Formatter {
color_format_string: "format string with color support".to_owned(),
format_string: "format string".to_owned(),
timestamp_format: "timestamp format".to_owned()
};
Fields§
§color_format_string: String
Format string supporting special ASCII control characters
format_string: String
Format string NOT supporting special ASCII control characters
timestamp_format: String
Timestamp format string in strftime format
Implementations§
source§impl Formatter
impl Formatter
sourcepub fn new(
color_format_string: &str,
format_string: &str,
timestamp_format: &str
) -> Formatter
pub fn new( color_format_string: &str, format_string: &str, timestamp_format: &str ) -> Formatter
Creates a new formatter object.
Parameters
color_format_string
: Format string supporting special ASCII control charactersformat_string
: Format string NOT supporting special ASCII control characterstimestamp_format
: Timestamp format string in strftime format
Returns
A new Formatter
object with the specified format strings.
Examples
logging_rs::Formatter::new(
"[{{color.bright_blue}}{{timestamp}}{{end}}] [{{level}}] {{path}}: {{message}}",
"[{{timestamp}}] [{{level}}] {{path}}: {{message}}",
"%Y-%m-%d %H:%M:%S"
);
See also
sourcepub fn format<'a>(
&self,
output: Output,
level: Level,
message: &'a str,
arguments: Vec<(&str, &'a str)>
) -> String
pub fn format<'a>( &self, output: Output, level: Level, message: &'a str, arguments: Vec<(&str, &'a str)> ) -> String
Formats the given message.
Parameters
self
: The formatter objectoutput
: TheOutput
to write tolevel
: The logLevel
to use for formattingmessage
: The message to logarguments
: A vector of additional formatting arguments
Returns
A String
containing the formatted message.
Examples
formatter.format(
logging_rs::Output::default(),
logging_rs::Level::default(),
"Some message with an {{argument}}",
vec![("argument", "replaced value")]
);
See also
Trait Implementations§
source§impl Ord for Formatter
impl Ord for Formatter
source§impl PartialEq for Formatter
impl PartialEq for Formatter
source§impl PartialOrd for Formatter
impl PartialOrd for Formatter
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Formatter
impl StructuralEq for Formatter
impl StructuralPartialEq for Formatter
Auto Trait Implementations§
impl RefUnwindSafe for Formatter
impl Send for Formatter
impl Sync for Formatter
impl Unpin for Formatter
impl UnwindSafe for Formatter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more