macro_rules! log_trace {
($debug_object:expr) => { ... };
($debug_object:expr, $context:expr) => { ... };
($($arg:tt)*) => { ... };
}
Expand description
log_trace!
is a macro that logs trace-level messages.
§Usage
The log_trace!
macro can be used in three different ways:
-
log_trace!(debug_object)
: This logs the debug representation of thedebug_object
along with its type name and location information (file, line, column, module path). -
log_trace!(debug_object, context)
: This logs the same information as the first form, but also includes a context string that can provide additional information about the log message. -
log_trace!(format_string, args...)
: This logs a formatted message using the given format string and arguments. The format string should follow the same syntax as the standardformat!
macro.
§Examples
use logger_rust::*;
let x: i32 = 42;
log_trace!(x); // Logs: "TRACE 2023-06-09 14:57:47 [TRACE] src\<module>:L29/C1 - used: x ->> (42): 42 | Type: <i32> | ThreadId(4) ->> Timestamp: UN1686304667694020IX | Module <module>"
let y = "Hello, world!";
log_trace!(y, "greeting"); // Logs: "2023-06-09 14:57:47 [TRACE] src\<module>:L32/C1 - used: y ->> ("Hello, world!"): "Hello, world!" | Type: <&str> | ThreadId(4) ->> Timestamp: UN1686304667694335IX ->> Context: <greeting> | Module: <module>"
log_trace!(x, "{}"); // Logs: "TRACE used: x ->> (42): 42 | Type: <i32> ... <context is empty>"