Open gbowne1 opened 9 months ago
Morgan and Winston are already installed packages on the server side.. so..
To store the generated logs in a specific directory like /logs on either the client or server side, configure the logging libraries, such as morgan and winston, to write the logs to files in the desired location. Here's how you can achieve this for both client-side and server-side scenarios:
Server-Side (Node.js):
Using Winston:
Configure Winston to write logs to a file in the /logs directory on the server side. Example:
const winston = require('winston');
const path = require('path');
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: path.join(__dirname, 'logs', 'server.log') }),
],
});
logger.info('Informational message');
logger.error('Error message');
Using Morgan:
Configure Morgan to log requests to a file in the /logs directory. Example:
const morgan = require('morgan');
const fs = require('fs');
const path = require('path');
const accessLogStream = fs.createWriteStream(path.join(__dirname, 'logs', 'access.log'), { flags: 'a' });
app.use(morgan('combined', { stream: accessLogStream }));
use one or the other.. uninstall the one not used and remove it from the requires @gbowne1 @jarmentor @Sky-De @Amrani-Farouk-Hossam-Eddine
There are plenty of good server side packages installed for doing logging.
Some sort of server side logging might be useful to the streamer and anyone trying to work with the bot to sort out issues.