pub struct LogLineWrapper { /* private fields */ }
Expand description
A wrapper around a log line that provides formatted and cached representations.
This struct contains a log line and provides various formatted versions of it, such as plain string, colored string, and JSON. It also caches the results for repeated calls, optimizing performance when the same message needs to be logged multiple times in different formats.
Implementations§
Source§impl LogLineWrapper
impl LogLineWrapper
Sourcepub const fn new(line: LogLine, trader_id: Ustr) -> Self
pub const fn new(line: LogLine, trader_id: Ustr) -> Self
Creates a new LogLineWrapper
instance.
Sourcepub fn get_string(&mut self) -> &str
pub fn get_string(&mut self) -> &str
Returns the plain log message string, caching the result.
This method constructs the log line format and caches it for repeated calls. Useful when the same log message needs to be printed multiple times.
Sourcepub fn get_colored(&mut self) -> &str
pub fn get_colored(&mut self) -> &str
Returns the colored log message string, caching the result.
This method constructs the colored log line format and caches the result for repeated calls, providing the message with ANSI color codes if the logger is configured to use colors.
Sourcepub fn get_json(&self) -> String
pub fn get_json(&self) -> String
Returns the log message as a JSON string.
This method serializes the log line and its associated metadata (timestamp, trader ID, etc.) into a JSON string format. This is useful for structured logging or when logs need to be stored in a JSON format.
§Panics
Panics if serialization of the log event to JSON fails.
Trait Implementations§
Source§impl Clone for LogLineWrapper
impl Clone for LogLineWrapper
Source§fn clone(&self) -> LogLineWrapper
fn clone(&self) -> LogLineWrapper
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more