ferron/common/log.rs
1/// Represents a log message with its content and error status.
2pub struct LogMessage {
3 is_error: bool,
4 message: String,
5}
6
7impl LogMessage {
8 /// Creates a new `LogMessage` instance.
9 ///
10 /// # Parameters
11 ///
12 /// - `message`: The content of the log message.
13 /// - `is_error`: A boolean indicating whether the message is an error (`true`) or not (`false`).
14 ///
15 /// # Returns
16 ///
17 /// A `LogMessage` object containing the specified message and error status.
18 pub fn new(message: String, is_error: bool) -> Self {
19 Self { is_error, message }
20 }
21
22 /// Consumes the `LogMessage` and returns its components.
23 ///
24 /// # Returns
25 ///
26 /// A tuple containing:
27 /// - `String`: The content of the log message.
28 /// - `bool`: A boolean indicating whether the message is an error.
29 pub fn get_message(self) -> (String, bool) {
30 (self.message, self.is_error)
31 }
32}