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

Logging #6

Closed
fwoelffel opened this issue Jan 30, 2018 · 5 comments
Closed

Logging #6

fwoelffel opened this issue Jan 30, 2018 · 5 comments
Milestone

Comments

@fwoelffel
Copy link

fwoelffel commented Jan 30, 2018

Hi there

Currently, the only way to remove the log output from this module is to set NODE_ENV to production.
Moreover, axios is expected to run in Node.js and in browsers: I don't think there is a way to set such a variable in the later environment.

Could we consider using the debug package instead of console.log ?
(See https://github.com/visionmedia/debug#browser-support)

@kuitos
Copy link
Owner

kuitos commented Jan 31, 2018

Maybe u need webpack to bundle your scripts and then do the configuration:

new webpack.DefinePlugin({
  'process.env.NODE_ENV': JSON.stringify('production')
})

https://webpack.js.org/guides/production/#specify-the-environment

@fwoelffel
Copy link
Author

Still, the logging is currently polluting my dev environment logs. I'm willing to submit a PR if you're interested in logging with debug.
This article may help you understand my concern https://blog.risingstack.com/node-js-logging-tutorial/

It is not recommended to pollute the log files with your events when others use the module you build. However, in some cases, application developers may need it to understand better why a given issue arose.

@kuitos
Copy link
Owner

kuitos commented Feb 1, 2018

It designed for developer to help them realized which request had been cached, given them more runtime information, in my purpose.

The debug is awesome but import a non-standard logger module for that simple requirement is not a good idea, which will also increases integration difficulties with a nodejs manager log system, such as pm2.

Maybe I need to use another environment variable for logging switcher rather than NODE_ENV, and then the logging is off in default and u can switch on manually if u need.

new webpack.DefinePlugin({
  'process.env.LOGGER_LEVEL': JSON.stringify('debug')
})

@fwoelffel
Copy link
Author

That'd be great :)

kuitos added a commit that referenced this issue Feb 1, 2018
@kuitos kuitos added this to the v1.2.0 milestone Feb 1, 2018
@kuitos
Copy link
Owner

kuitos commented Feb 1, 2018

released at v1.2.0, see https://github.com/kuitos/axios-extensions#enable-logging
Thanks for your feedback!😀

@kuitos kuitos closed this as completed Feb 1, 2018
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