gbowne1 / RadioLogger

A Radio Logging application build with NodeJS and ExpressJS
GNU General Public License v3.0
6 stars 6 forks source link

[TODO] Create some logging #16

Closed gbowne1 closed 1 year ago

gbowne1 commented 1 year ago

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.

jzunigarce commented 1 year ago

Assign it to me

gbowne1 commented 1 year ago

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.

gbowne1 commented 1 year ago

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 }));
jzunigarce commented 1 year ago

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

gbowne1 commented 1 year ago

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.

gbowne1 commented 1 year ago

I tested this this afternoon. It does create some good logs. Very useful

jzunigarce commented 1 year ago

Can we meet on a video call to go over some details?

gbowne1 commented 1 year ago

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.

gbowne1 commented 1 year ago

Closed as completed.