Download / ulog

The universal logger
https://ulog.js.org
MIT License
88 stars 19 forks source link

Logging via format string no longer works, advice please #72

Open toddb opened 3 years ago

toddb commented 3 years ago

@Download in version one, I could write a positional string formatter.

log.debug('setting return-url: %s', uri);

Now, it seems the default is to use template strings (presumably kurly);

log.debug(`setting return-url: ${uri}`);

With my old format, I now get

image

I can't quite grok how to swap back to the original format. Is is possible?

Cheers

ps I have been sitting on this change for quite a while and only now trying to address it.

Download commented 2 years ago

@toddb Sorry for the late response. Ulog v1 did not support formatters. The formatting syntax you were using is actually console native. Because ulog did not do any formatting of it's own, you could use the positional formatters and they just worked. Ulog v2 supports colored / formatted output. This uses (abuses) some features of the console. One of which is to rely on positional formatters for the colors and on Function.apply to not disturb the call stack. To support formats this way actually messes with the positional formats. Please try to set colors and align off and to not use any formats. My guess is you will get the old behavior back. I think that if you use a dynamic format, you will also get the old behavior. But using colors / align / a static format (that does not mess up the callstack) probably messes up positional formatting.... Please do some testing with these settings and let me know what you found.