web3.storage icon indicating copy to clipboard operation
web3.storage copied to clipboard

chore: set DEBUG to false in the 'test' env to silence logging debug statements

Open adamalton opened this issue 2 years ago • 1 comments

This is a follow up to Alan's comment here: https://github.com/web3-storage/web3.storage/pull/1346#issue-1244957912

I've gone with changing the DEBUG env var to 'false' in wrangler.tom., as the only other place where we compare that var to 'true' is in packages/api/src/env.js in the Sentry setup. But given that SENTRY_DSN isn't set for the env.test/local environment, Sentry won't be getting initialised anyway. So I don't think this affects any other debug configuration.

An alternative would be to use the pattern of:

import debug from 'debug'
log = debug('logging')

But given that there are already several methods and variables called log and debug in the logging.js file, including in the scopes where we would want to call log(), that might cause more confusion than it's worth! Plus doing it the way I've done it keeps the code more similar to the implementation that's in nft.storage.

adamalton avatar May 30 '22 16:05 adamalton

@olizilla I'm not sure exactly what you mean by your comment. Are you saying that we should go for a different fix in order to prevent the Logtail logging in dev/test?

adamalton avatar Jun 27 '22 12:06 adamalton

I've updated the original title and description to what I think was the original intent of Alan's comment.

For reference here's the old ticket details:

Original ticket: Title chore: set DEBUG to false in the 'test' env to silence logging debug statements Description:
This is a follow up to Alan's comment here: https://github.com/web3-storage/web3.storage/pull/1346#issue-1244957912

I've gone with changing the DEBUG env var to 'false' in wrangler.toml, as the only other place where we compare that var to 'true' is in packages/api/src/env.js in the Sentry setup. But given that SENTRY_DSN isn't set for the env.test/local environment, Sentry won't be getting initialised anyway. So I don't think this affects any other debug configuration.

An alternative would be to use the pattern of:

import debug from 'debug'
log = debug('logging')

But given that there are already several methods and variables called log and debug in the logging.js file, including in the scopes where we would want to call log(), that might cause more confusion than it's worth! Plus doing it the way I've done it keeps the code more similar to the implementation that's in nft.storage.

flea89 avatar Aug 31 '22 14:08 flea89

Website preview 🔗✨

  • 🙂 https://w3s.link/ipfs/bafybeie2bjzirquq4ur2glsxag3utcj5w7chtjf37bugisrmwkyqhql7n4
  • ⛅️ https://87eb34a0.web3-storage-staging.pages.dev

build log

github-actions[bot] avatar Sep 02 '22 09:09 github-actions[bot]

@olizilla, I stumbled upon this PR and I've reworked it to tackle what was the original purpose. Can please confirm that's the case 🙏 before we merge it in?

flea89 avatar Sep 02 '22 10:09 flea89

I'm +1 on the fix here... but could you close this PR and open fresh one without the linting noise (I had to do the same here on old PR https://github.com/web3-storage/web3.storage/pull/1593#issuecomment-1237056568)

olizilla avatar Sep 08 '22 14:09 olizilla

Sure, I'll try that.

flea89 avatar Sep 09 '22 10:09 flea89

New PR to be linked.

mbommerez avatar Sep 12 '22 09:09 mbommerez