mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-07-29 18:25:47 +02:00
Helpers + Clean Download et Info
This commit is contained in:
@@ -1,26 +1,9 @@
|
||||
/*
|
||||
This file is part of Freedom Loader.
|
||||
|
||||
Copyright (C) 2025 MasterAcnolo
|
||||
|
||||
Freedom Loader is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License.
|
||||
|
||||
Freedom Loader is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const { createLogger, format, transports } = require("winston");
|
||||
const DailyRotateFile = require("winston-daily-rotate-file");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const os = require("os");
|
||||
const config = require("../config")
|
||||
|
||||
// Dossier de logs Windows
|
||||
const logDir = path.join(os.homedir(), "AppData", "Local", "FreedomLoader", "logs");
|
||||
@@ -28,18 +11,11 @@ const logDir = path.join(os.homedir(), "AppData", "Local", "FreedomLoader", "log
|
||||
// Création du dossier si nécessaire
|
||||
fs.mkdirSync(logDir, { recursive: true });
|
||||
|
||||
// Format commun pour tous les logs
|
||||
const logFormat = format.combine(
|
||||
format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
||||
format.printf(({ timestamp, level, message }) => `${timestamp} | ${level.toUpperCase()} | ${message}`)
|
||||
);
|
||||
|
||||
const consoleFormat = format.combine(
|
||||
format.colorize(),
|
||||
format.timestamp({ format: "HH:mm:ss" }),
|
||||
format.printf(({ timestamp, level, message }) => `${timestamp} | ${level} | ${message}`)
|
||||
);
|
||||
|
||||
// Configuration du logger
|
||||
const logger = createLogger({
|
||||
level: "info",
|
||||
@@ -55,12 +31,11 @@ const logger = createLogger({
|
||||
options: { flags: "a" },
|
||||
}),
|
||||
new transports.Console({
|
||||
format: consoleFormat,
|
||||
format: logFormat,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
// Helpers pour sessions
|
||||
function getSessionStartLine() {
|
||||
return `--- Démarrage de la session : ${new Date().toISOString()} ---`;
|
||||
}
|
||||
@@ -71,16 +46,16 @@ function getSessionEndLine() {
|
||||
|
||||
function logSessionStart() {
|
||||
logger.info(getSessionStartLine());
|
||||
logger.info(`Version de l'Application: ${config.version}`)
|
||||
}
|
||||
|
||||
function logSessionEnd() {
|
||||
logger.info(getSessionEndLine());
|
||||
}
|
||||
|
||||
// Export
|
||||
module.exports = {
|
||||
logger,
|
||||
logSessionStart,
|
||||
logSessionEnd,
|
||||
logDir,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user