Is the npm install debug output a standard format, and if so, what is it?


(Damien Golding) #1

I posted the same question to Stackoverflow but have had no responses.

I have checked the docs, but can’t find any information.
As mentioned on Stackoverflow, I am interested in parsing the debug output so I can handle warnings.

Any help would be much appreciated, regards.


(Brian Thompson) #2

Hello, I don’t think any documentation exists for what you’re asking for.

I believe that starting such documentation would be awesome. Perhaps we could switch this thread with an “idea” tag.


(Lars Willighagen) #3

The logging is done with npmlog, but I couldn’t find real documentation on what that looks like. In practice the debug log has on each line:

  1. The log number, different from the line number because some log messages are multi-line while the prefix is kept on each line
  2. The log level
  3. The prefix
  4. The message

The normal stderr output (with -ddd) doesn’t include the log number, but an npm prefix.You can generate a debug log with --timing, but it writes to a file and you’d have to extract the file name from stderr.


(Damien Golding) #4

Is adding an “idea” tag something I as the author need to do? Or is there a better way?


(Damien Golding) #5

Thanks. I checked the npmlog repository and found some useful information about the log levels:
https://github.com/npm/npmlog/log.js

log.addLevel('silly', -Infinity, { inverse: true }, 'sill')
log.addLevel('verbose', 1000, { fg: 'blue', bg: 'black' }, 'verb')
log.addLevel('info', 2000, { fg: 'green' })
log.addLevel('timing', 2500, { fg: 'green', bg: 'black' })
log.addLevel('http', 3000, { fg: 'green', bg: 'black' })
log.addLevel('notice', 3500, { fg: 'blue', bg: 'black' })
log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN')
log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!')
log.addLevel('silent', Infinity)

The 4th argument overwrites the level key as the displayed name.


(Lars Willighagen) #6

This category is fine for documentation requests. About the 📖 docs-needed category :

missing, incorrect, or hard-to-find docs? request and suggest them here!

Apart from that, yes, you should be able to change the category if I’m not mistaken. I could do so too, but there’s no point to that at the moment.