UNPKG

loggers-factory

Version:

Javascript package that makes the use of loggers a breath.

51 lines (34 loc) 1.6 kB
// TODO: Faire en sorted que ca marche ?! mdr ^_^ const fs = require("fs"); function rotate(old_file_path, new_file_path, on_limit) { return; // If I can spawn a child process I do it in order to not block the event loop ;) // old_filename = old_file_path.replace(join(process.env.ROOT_PATH, 'logs'), ''); // new_filename = new_file_path.replace(join(process.env.ROOT_PATH, 'logs'), ''); // prefix = old_filename.split('.')[0].replace('/', ''); // old_day = old_filename.split('.')[2].split('-')[0]; // new_day = new_filename.split('.')[2].split('-')[0]; // if (old_day !== new_day){ // old_date = old_filename.split('.')[2].split(':')[0]; // old_date_dir = join(process.env.ROOT_PATH, `logs/archives/${old_date}`) // if (!fs.existsSync(old_date_dir)){ // // Create the directory if it does not exist // fs.mkdirSync(old_date_dir); // } // if (!fs.existsSync(join(old_date_dir, prefix))){ // // Create the directory if it does not exist // fs.mkdirSync(join(old_date_dir, prefix)); // } // fs.readdir(join(process.env.ROOT_PATH, 'logs'), (error, files_list) => { // for (let file of files_list){ // if (join(process.env.ROOT_PATH, `logs/${file}`).split(':')[0] === old_file_path.split(':')[0]){ // let new_file_path = join(process.env.ROOT_PATH, `logs/archives/${old_date}/${'combined'}/${file}`); // fs.rename(old_file_path, new_file_path, error => { // console.log(join(process.env.ROOT_PATH, `logs/${file}`) , old_file_path,prefix,error) // }); // } // } // }); // } } module.exports = rotate;