Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent string interpolation #62

Open
magixx opened this issue Oct 3, 2017 · 1 comment
Open

Inconsistent string interpolation #62

magixx opened this issue Oct 3, 2017 · 1 comment

Comments

@magixx
Copy link

magixx commented Oct 3, 2017

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants