Inconsistent string interpolation
magixx opened this issue · 1 comments
magixx commented
I'm sure this is likely an issue with the way I've set things up (latest node, bable, webpack, ) but I cannot get string interpolation to work when using Logger.get
. ex:
import Logger from 'js-logger'
Logger.useDefaults()
Logger.warn('TEST')
Logger.warn('TEST %sPOLATED', 'INTER')
const log = Logger.get('Log')
log.warn('Test')
log.warn('TEST %sPOLATED', 'INTER')
Will output:
TEST
TEST INTERPOLATED
[Log] Test
[Log] TEST %sPOLATED INTER
So what am I not understanding here?
In addition, if I do not use Logger.useDefaults()
, for example by replacing that line with Logger.setLevel(Logger.INFO)
, I won't see any logs at all. Any thoughts as to why this occurs?
jonnyreeves commented
Hi @magixx, sorry for the slow response.
Yep, the broken string interpolation is indeed a bug caused by the default log message formatter which will unshift
a named Logger's name into the messages array; as you may be aware, console.log()
and friends will only perform interpolation on first value.