Duffer Derek

Current Path : /var/www/api-mk-planner.bitkit.dk/httpdocs/Backend/src/configs/
Upload File :
Current File : /var/www/api-mk-planner.bitkit.dk/httpdocs/Backend/src/configs/logger.js

import { createWriteStream, existsSync, mkdirSync } from 'fs';
import { join } from 'path';
import deleteFilesInLogsFolder from '../services/deleteLogFiles.js';

deleteFilesInLogsFolder();
// Ensure the 'logs' directory exists
const logsDirectory = './logs';
if (!existsSync(logsDirectory)) {
  mkdirSync(logsDirectory);
}

var datetime = new Date();
const formattedDate = datetime.toISOString().slice(0, 10);

// Construct the log file paths
const outputLogPath = join(logsDirectory, `outputLog${formattedDate}.log`);
const errorsLogPath = join(logsDirectory, `errorsLog${formattedDate}.log`);

// Create WriteStreams for output and errors logs
const outputLog = createWriteStream(outputLogPath, { flags: 'a' }); 
const errorsLog = createWriteStream(errorsLogPath, { flags: 'a' }); 

const Log = new console.Console(outputLog, errorsLog);

export default Log;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists