I was wondering how I am suppoed to do client side logging in react ? Currently im using redux-logger to lok my redux actions and thats working great but i want to do sort of more generic logging too.
The application however gets built on a docker image and has to be as small as possible. Currently i have redux-logger as a dev dependency and wrap with an if statement to check whether or not im in production mode:
if (process.env.NODE_ENV === 'production') {
store = createStore(rootReducer, applyMiddleware(...middlewares));
} else {
// Get logger and redux dev tools
const { logger } = require('redux-logger');
const { composeWithDevTools } = require('redux-devtools-extension');
// push the logger to middlewares to be used
middlewares.push(logger);
// and create the store
store = createStore(
rootReducer,
composeWithDevTools(
applyMiddleware(...middlewares)
// other store enhancers if any
)
);
}
What is the best way of logging information without having to manually wrap a console.log() inside an if statement every time i want to log information ?
Looking forward to learning new approaches to logging on the client. Thank you very much !