Better logging in npm ... use winston #539

Closed
indexzero opened this Issue Jan 30, 2011 · 9 comments

Projects

None yet

2 participants

@indexzero
Contributor

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
Member
isaacs commented Jan 30, 2011

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

@isaacs
Member
isaacs commented Jan 30, 2011

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
Contributor

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

@isaacs
Member
isaacs commented Jan 30, 2011

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
Contributor

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
Member
isaacs commented Jan 30, 2011

Done. 63b5434

@indexzero
Contributor

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

@isaacs
Member
isaacs commented Jan 30, 2011

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

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

@indexzero
Contributor

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 pushed a commit to bmeck/npm that referenced this issue Dec 20, 2011
@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