-
Notifications
You must be signed in to change notification settings - Fork 1
Add logging #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Add logging #8
Conversation
|
In the latest commit I added more verbose error logging in this PR instead of another. I decided they were related enough to include in this PR and save time. Using the various error codes that can happen I created a switch statement that populates messages for the user/log based on error code. If there is no matching error code that means it was either an unhandled error or a server error. One thing I forgot to mention in the original message. The timestamp in the error message is GMT. Do we want to use GMT or EST? |
|
Excellent work @KevinKelly25. Please review my suggestions. |
|
Yes, UTC is the correct time zone to use. |
Co-Authored-By: Sean Murthy <murthys@wcsu.edu>
|
The latest commits should resolve all outstanding comments. Thank you @smurthys for reviewing my work and making suggestions. |
|
The latest commit makes it so the path to where logs are created can be added via an environmental variable. To achieve this I added the module dotenv. This module takes the variables from a In order to get this latest commit to work you will need to create a file |
This PR adds logging via the winston package to
routes/user.js. The filewinston.jswas added to create the logger and export it for ease of use. Winston is pretty flexible and can be customized in many ways. Because of that I am creating this PR as a baseline for discussion on how we want to format our logs.The current format is as follows:
Timestamp log-level: ( Route ) User: {username} info-messageAn example:
2019-08-23T20:52:27.151Z info: (Change-Password) User: teststu2 attempting to change passwordThere is two log files
combined.loganderror.log. Thecombined.loghas all logs anderror.logcontains only theerrorlevel logs.Currently, everything that results in
.errorafter the database query is getting put intoerrorlog level but in another PR we will be expanding the error functionality to handle different types of errors in different ways. For example, if the username was incorrect and it fails the query because of that it will be logged ininfonoterror.errorshould likely only be used for server errors or uncaught errors.