pimterry / loglevel

:ledger: Minimal lightweight logging for JavaScript, adding reliable log level methods to wrap any available console.log methods
MIT License
2.62k stars 157 forks source link

Plugin example from readme doesn't work #60

Closed artemyarulin closed 9 years ago

artemyarulin commented 9 years ago

Hi, thank you for your project.

Maybe I'm missing something but I cannot get your example plugin from readme working. It should add prefix for each log level, but at the end it does nothing. Here jsfiddle

Doesn't work in latest Chrome

artemyarulin commented 9 years ago

OK, I found two reasons for that: 1) CDN url was outdated (it was pointing to v.0.0.6) (see #61 ) 2) replaceLoggingMethods has to be called after log.methodFactory replacement. The easiest way is to make a call through setLevel function. I'm not sure - it this a bug or expected behavior? If yes - it should be mentioned in README

Thanks

pimterry commented 9 years ago

Ah, nice spot, yes. I think I must've been calling setLevel myself when I set that up. Would you be up for updating the docs to cover this?

An alternative solution where we add a setter or something for methodFactory which automatically rebuilds the logging methods would be fine too, but probably trickier.

artemyarulin commented 9 years ago

Great - I'll create a pull request. On a side note - do you have somewhere list of loglevel plugins? I'm thinking of creating one (to send logs to the server), maybe it exists already?

pimterry commented 9 years ago

Not yet; the plugin API was only added relatively recently, and I think this would be the first. Very happy to add one to the README though.

artemyarulin commented 9 years ago

Cool to be the first one :) Here the loglevel-serverSend, works for me and with your project my development life became a little bit easier, thanks again!