Closed gbowne1 closed 1 year ago
Assign it to me
Tomorrow morning I can show examples of wiring up both morgan and winston so they work together. One is for HTTP requests and we should use both.
This would be something like this:
const winston = require('winston');
const morgan = require('morgan');
const logger = winston.createLogger({
transports: [
new winston.transports.Console({
level: 'debug',
handleExceptions: true,
json: false,
colorize: true
}),
new winston.transports.File({
level: 'info',
filename: './logs/all-logs.log',
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false
})
],
exitOnError: false
});
logger.stream = {
write: function(message, encoding) {
logger.info(message.trim());
}
};
app.use(morgan('combined', { stream: logger.stream }));
I'm going to configure winston to replace the console.logs and also created a module to handle morgan. I will stop the middleware in another file to make the server.js a bit cleaner
I actually like that idea and actually was headed that direction with some thoughts I had.
I will push up the initial work I did with the README.md and the TODO.md replacing a bunch of the Issues. We should use that for stuff we need to get done.
I tested this this afternoon. It does create some good logs. Very useful
Can we meet on a video call to go over some details?
Like what? I still have plenty to document and work on. You can always use Discussion tab for conversation about the project, that are separate from an issue.
Closed as completed.
We now have morgan and winston installed on the server.
These are loggers.
Save server logs to /src/server/logs/
They wont be pushed to github for obv reasons but we should always do logging.