Closed kachkaev closed 2 months ago
How about a behavior that strips out the whitespace to find the variable if there is leading and trailing whitespace in a template variable and it doesn't match exactly?
logger.info("value = { foo }", { " foo ": 1, foo: 2 });
// INF value = 1
logger.info("value = { foo }", { foo: 2 });
// INFO value = 2
Perfect, thanks! 🚀
👋 @dahlia! Just started playing with logtape – awesome architecture!
I faced a small issue with template literals and decided to share. Technically, there is no bug, it's just a small DX trap that could be avoided.
It turned out that
{foo}
and{ foo }
were not the same thing, which caught me:Because I use Prettier and it puts whitespace around
{
}
in objects, I uncontentiously did the same in template literals. It took a bit of time to figure out what was going on.Here is an idea: if we detect dev mode and there is a key mismatch like
' hello '
/'hello'
, logtape could log a warning and explaining the situation. Or maybe it could even ‘forgive’ spaces around braces. This could help folks with onboarding, because every new team member who uses logtape for the first time can accidentally fall into the same trap as I did.WDYT?