Reputation: 881
I use the successful git workflow, the one with a master, a develop and feature branches.
My problem is, during development, logging lines are not commented. I mean certain code statements that logs several data. Now once a release is ready we comment the logging lines (they are not many but they log a lot of data).
Now once we merge in master and make a tag, we then fast forward develop. Now development starts again and we uncomment the logging lines, causing changes which needs to be committed.
So the problem is whenever a release happens, 2 useless commits are committed, one for commenting the logging lines and one for uncommenting them.
What can we do in order to improve this process?
Upvotes: 0
Views: 54
Reputation: 9770
You shouldn't comment out your log lines. Instead you should configure your log level in your local dev environment.
When you run on your local dev machine you can generally assume that you are in development mode. When you deploy to production you are in production mode. You should include your production log configuration in git. The you can use .gitignore
to ignore a local configuration file which overrides that standard production configuration.
In express.js, you can use app.get('env')
to get the current environment. See http://expressjs.com/4x/api.html#app.settings.table for more details.
I haven't used morgan, so I'll have to try to figure out the specifics, but hopefully these general guidelines will get you in the right direction.
Regarding specifics about morgan, it appears these two answers both do a good job of explaining how to use morgan differently based on the environment:
This first answer combines morgan with log4js
and sets morgan to use the log4js
logger stream to output its log info.
This second answer changes the behavior based on the environment as mentioned before using app.get('env')
.
Upvotes: 1