Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Better logging in npm ... use winston #539

Closed
indexzero opened this Issue · 9 comments

2 participants

@indexzero

I had an interesting idea today: I would love to see my npm logs in Loggly

There are two ways we could accomplish this:

  1. Have npm use something log node-syslog: https://github.com/cloudhead/node-syslog
  2. Have npm write logs using winston and make the loggly input configurable

I think that (2) is more amicable for the existing code base since you don't use syslog logging levels. Let me know how I can help out on this one.

@isaacs
Owner

Can you just hook into npm.on("log", function (msg) { ... })?

@isaacs
Owner

By that I mean, I think that you're one of the few folks who'd benefit from this. Most people use npm while they're staring at it, so this wouldn't be much of a win for them.

@indexzero

hmmm ... you're probably right. Although not all of our npm use is programmatic, so it's not 100% coverage for us.

@isaacs
Owner

Hm. What if npm pulled in some user-specified "onload" script on startup, and then you could just attach the event listener there if you wanted? I'm thinking something like this in npm's load function:

var onload = npm.config.get("onload-script")
if (onload) require(onload)

Then, in there, you could do: require("npm").on("log", function (msg) { chillWinStahn(msg) })

@indexzero

That could be really useful for a number of reasons, not just this. I like the idea, and it would definitely provide 100% coverage for us.

@isaacs
Owner

Done. 63b5434

@indexzero

Great. Quick question: Is this a path to a script or an actual piece of code?

@isaacs
Owner

Path to a script. It's passed into require().

I guess it might make more sense to call it onload-module?

@indexzero

No, I think onload is fine, but maybe have a quick example that indicates it's a path to a script and not raw code

@bmeck bmeck referenced this issue from a commit in bmeck/npm
@isaacs isaacs Fix #539 Implement configurable "onload-script" 63b5434
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.