One of the devs I work with said he considered checking the environment (e.g. process.env.NODE_ENV == production), and configuring the application based on the running environment ‘a code smell.’ He suggested we break this out into an environment variable, instead.

For this particular example, we wanted logging to act differently in dev & test (human readable output) vs production (json output). This resulted in a statement similar to the following:

let logFormat if (process.env.NODE_ENV == 'production') { logFormat = winston.format.json() } else { logFormat = winston.format.simple() } 

What’s your take on this? Are there any well-written articles supporting this practice, or advising against this technique?

submitted by /u/beast_master
[link] [comments]