jaysylvester / citizen

Node.js MVC web application framework. Includes routing, serving, caching, session management, and other helpful tools.
MIT License
100 stars 7 forks source link

Reconsider logging logic and its relationship to the application mode setting #93

Closed jaysylvester closed 3 years ago

jaysylvester commented 3 years ago

There's actually very little left in citizen that relies upon the application mode to determine behavior. Consider moving the logic based on app mode currently within helpers.log() into an if statement outside the function call to make its behavior more predictable (e.g., most calls to helper.log() in server.js are only relevant in dev mode, so that's a lot of function calls that end up running a check on the app mode and then not doing anything).

Also reexamine logging behavior and consider whether it should be driven by application mode or all the booleans in the config. It's currently a mix of both and it's confusing. It should probably be either a) simplified logging logic based on app mode, or b) driven entirely by the config settings with app mode left out of it.

Simplified logging might entail:

  1. Development mode a. Verbose console logging with in-depth debugging b. No file logs
  2. Production mode a. No console logging b. Minimal file logs for requests (time, remote host IP, possibly user agent, and requested resource) c. More verbose file logs for errors (400 and 500 level) with stack trace