krakenjs/beaver-logger

logLevel not defined in docs

ap1969 opened this issue · 3 comments

Hi,
I've just spent a bit of time trying to work out why the logs are being sent to the remote API, but not appearing in console.

Turns out I was using logger.info(), and that's not rendered due to the logLevel in config defaulting to "warn".

Would be great to have this in the docs! :-)

Regards,
Andy

A related issue: although logger.info() messages weren't being sent to the console, they were being sent to the remote API even though the config was set to logLevel: warn. Presumbably, this shouldn't be the case?

Andy

Hi,
I don't have access to GIT here, but I added (locally) the following to the start of the enqueue() function, and it mimics the console filtering out of less-urgent messages.

var logLevel = window.LOG_LEVEL || _config.config.logLevel;
if (_config.logLevels.indexOf(level) > _config.logLevels.indexOf(logLevel)) {
       return;
}

logLevel is typically more about deciding whether to display logs, rather than deciding whether to persist them. So a logger.info() call should always make it to your server-side, then ideally you should have some server-side logLevel which determines which logs to persist / send to your logging backend.