Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Unnecessary processing incase the log level is lower than the set level. #36

Closed
samarth opened this issue May 27, 2016 · 1 comment
Closed

Comments

@samarth
Copy link

samarth commented May 27, 2016

I set the log level to "INFO" on production systems .

My code had a lot of verbose statements spread across it and in some cases , there was a massive json placed inside the logger. This led to a severe spike in latency on the average response times.

There already is an option of not writing to the stdout if the statement log level is lower than the general setting but we still do a lot of unnecessary processing in the log.log function (the culprit in my case was util.format)

Can we had the log level check in the log.log function itself ? Or is there some reason that you've added this in the emitLog function ?

Thanks .

DivineGod added a commit to DivineGod/npmlog that referenced this issue Jun 7, 2016
As reported in npm#36 the `log.log`
function will do processing of log messages even if the `log.level`
is higher than the message level.

This change will break systems expecting the event emitter to emit
log messages for every call to `log.log` as well as having `log.record`
only contain a list of messages that have the appropriate level
DivineGod added a commit to DivineGod/npmlog that referenced this issue Jun 7, 2016
As reported in npm#36 the `log.log`
function will do processing of log messages even if the `log.level`
is higher than the message level.

This change will break systems expecting the event emitter to emit
log messages for every call to `log.log` as well as having `log.record`
only contain a list of messages that have the appropriate level
@iarna
Copy link
Contributor

iarna commented Jun 9, 2016

As I said over in #39, we need that where it is because we need log.record to have all log levels so that npm-debug.log files produced on crash can contain useful information. As things are structured today, I don't see a way to save you that computation. =/

@iarna iarna closed this as completed Jun 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants