As mentioned in other posts, I’m working on a package called Term.jl that does a bunch of pretty terminal stuff like printing formatted error messages:
One of the features I’d like to add is formatted logging. Similar to the built-in logging system but with fancier formatting. Such that:
function foo() x = 1 @info "this sis sodifsdfnso" 1+1 x 2x @tinfo "this sis sodifsdfnso" 1+1 x 2x end
which would normally give
would give something with a bit more color:
However I can’t quite figure out how the logging code in
Base evaluates symbols and expressions to produce the logging message. E.g if while handling that log message I try to evaluate
2x I get an error saying that
x is not defined (as it isn’t within the
@tinfo macro). I’ve looked in details at julia/logging.jl, but the code is fairly dense and I can’t quite figure out how they get the values associated with variables/symbols passed to the logging macros. I suspect that it’s handled by
log_msgcode, but I can’t figure out what that function does exactly.
Any help would be appreciated!