Closed ethyde closed 7 years ago
Hi @ethyde,
Attached you will find a complete example, which uses the plugin in the backend and the frontend. Does this fix the problem? :-)
# unpack the tar.gz file
tar xfzv logger-example.tar.gz
cd logger-example
# install the required modules
yarn # or: npm install
# build all
npm run build
# run the backend
npm start
# open the frontend: http://localhost:3000/
Just published the example as github project here: https://github.com/core-process/logger-example
It's works ! Thanks a lot.
Just another question, is it possible to make it conditional depending on the production or development NODE_ENV value ?
@ethyde Awesome!
Currently it is not supported, but we could generate a dummy logger variable when in production mode which provides NOOP logging routines. I will look into this next week.
In case you want to develop this feature yourself, please provide a pull request :-)!
@ethyde
Well actually, we do not need any magic for this.
You could evaluate your conditions in the initialization routine (e.g. https://github.com/core-process/logger-example/blob/master/src/frontend/logger-init.js#L2) and use Logger.setLevel(Logger.OFF);
.
See https://github.com/jonnyreeves/js-logger for more.
const Logger = require('js-logger');
Logger.useDefaults();
if(process.env.NODE_ENV == 'production') {
Logger.setLevel(Logger.OFF);
}
@ethyde Just updated https://github.com/core-process/logger-example to enable configuration of logging via NODE_ENV.
Many Thanks for your quick and nice help ! :)
Hello,
I try to use your plugin with a basic Webpack/Babel Configuration, but i never be able to use
logger.info
, there is no error, but no logs too.Can you help me ?
My confing :
.babelrc
webpack.config.babel.js
package.json