yibn2008/find-process

Adding logging level configuration

blakef opened this issue · 2 comments

The API doesn't allow control over the logging levels surfaced to the user. There are very sane defaults if you're using find-process in the CLI, however if you're using it as a library you can't silence this output from netstat:

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)

I'm wondering if you'd be open to a pull request to use a simple logging framework like loglevel (0 dependencies), and allow for configuring a logging level. Possibly update to this signature:

interface Options {
  loglevel: LogLevelDesc?;
  strict: boolean?;
}

function find(by, value, options?: Options | boolean) {
  const opts = Object.assign({
    loglevel: 'warn',
    strict: typeof strict === 'boolean' ? strict : !!option.strict,  
  }, options);
  ...
}

Very happy to put together a pull request, but wanted to gauge if there was any interest first.

Looks reasonable to me, I will accept the pr

Looks like this PR was merged but not redeployed... super useful feature; would you be able to redeploy to npm @yibn2008 ?