Replies: 1 comment 1 reply
-
Cool! The log macro is intended as a very thin wrapper over println (on the server) or console.log (in the browser), because println doesn't work in the browser. For any real logging purposes I'd recommend using the tracing or log crates. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We all know how convenient (and necessary) it is to use the
console log
to figure out what our well crafted and it-should-work code is doing.While its not a big deal, I also tend to find that including a timestamp (and the module name) to the log - an added bonus.
I have extended the
log!
macro to automatically prefix the logged message with thetimestamp info
. The timestamp format isYYYY-MM-DD HH:MM:SS.nnn
with an added 3 decimal place microsecond. The timestamp is book-ended by a pair of squared brackets[]
and the text is shown in the color -green
.Here is an example of a timestamped
console_log
messaage:[2023-12-30 01:03:43.814] ::PageOrientation::set_orientation::
and here is the extended macro, which I have called
tslog
.\x1B[32m
is the escape sequence for setting the text color to blue, and\x1B[0m
reset the color (to black in this case)and to use it,
Beta Was this translation helpful? Give feedback.
All reactions