Closed OmgImAlexis closed 7 years ago
I don't know vue. I'm surprised by the above though - why do you need to do that, why don't you just import log and then use it like any other library?
You need to import all the functions otherwise none of the log.* functions works.
For example log.info()
only works after importing info from loglevel
.
You also need window.log to use it within all of your .vue files otherwise it'll only work in the single file/component that it's imported into. If the user wanted they could just import it and bind log.noConlict()
to the Vue method field but that would limit log to only be usable for that single component.
Still not working for me (i'm using vue-cli
). Seems to be that loglevel
has not access to console and every log method end up being the default method noop
(function() {})
@mibanez did you use import * as log from 'loglevel';
? If you just import loglevel itself then nothing it set, that's why you end up with noop.
@OmgImAlexis not working either for me, did you actually test your code ? :/
Yes and I use it for multiple projects.
@OmgImAlexis worked , sorry
Glad to hear that all worked out. I'm not totally sure I'm following the above as a non-vue user. Are there some basic instructions for this vue setup that should be in the readme? If any of you want to put together a PR to add a short snippet for this (under Setting it up
), I'd be happy to include it.
@pimterry just including something like this would work; and it's for ES6 not vue specifically.
In ES6 make sure to import the whole package. The last line only applies while using ES6 in the browser as allows the use of log anywhere in your app.
import * as log from 'loglevel';
window.log = log.noConflict();
Since more and more people are starting to use Vuejs it may be an idea to add something to the docs to let them know how to get this library working.