Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No option to supress logs #31

Open
prashanthr opened this issue Nov 13, 2017 · 4 comments
Open

No option to supress logs #31

prashanthr opened this issue Nov 13, 2017 · 4 comments

Comments

@prashanthr
Copy link

When using clearbit to lookup info, a log is added to the console / stdout with the following signature

Making request #1 { protocol: 'https:',
  host: 'company-stream.clearbit.com',
  port: 443,
  path: '/v2/companies/find?domain=google.com',
  method: 'get',
  headers:
   { Accept: '*/*',
     Connection: 'close',
     'User-Agent': 'ClearbitNode/v1.3.3'
...

Currently there is no way to suppress these logs.
I believe the underlying root cause is the way clearbit/needle handles the logs. Since this is a forked version of needle, upgrading the version of needle could solve this issue as the new version of needle uses the debug module.
Code Reference:
node_modules/lib/needle.js line# 25

The best possible option is to provide a way for the clearbit-node client to suppress logs and perform the check in the underlying needle module.

var Client   = require('clearbit').Client
var clearbit = new Client({
   key: 'api_key'
   log: false
})
@jonluca
Copy link

jonluca commented Jul 17, 2018

👍 Agreed, it's polluting our logs as well.

@jonluca
Copy link

jonluca commented Jul 18, 2018

I did a little more digging.

The logs are output through a debug function in needle.js, which in turn prints those logs only if !!process.env.DEBUG is true. I don't want to turn debug off for the entire application, but I'm not sure how much clearbit themselves relies on these logs.

I will submit a PR to disable logs soon.

@jonluca
Copy link

jonluca commented Jul 18, 2018

PR #38

@prashanthr
Copy link
Author

Cool! In the meantime, we came up with a hack for this in our application. This may help you.

// Backup debug
const DEBUG_BACKUP = process.env.DEBUG

// Temporarily disable DEBUG if you don't want to see clearbit debug logs
if (!process.env.CLEARBIT_DEBUG) {
  process.env.DEBUG = ''
}

// Import clearbit package
const clearbit = require('clearbit')(YOUR_API_KEY)

// Import debug pacakge in your module
const debug = require('debug')('MY_MODULE')

// Restore DEBUG to it's original config
process.env.DEBUG = DEBUG_BACKUP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants