mirror of
https://github.com/ApfelTeeSaft/Reload-Backend.git
synced 2026-08-26 19:33:26 +00:00
123 lines
3.2 KiB
JavaScript
123 lines
3.2 KiB
JavaScript
const fs = require("fs");
|
|
const config = JSON.parse(fs.readFileSync("./Config/config.json").toString());
|
|
|
|
function getTimestamp() {
|
|
const now = new Date();
|
|
const date = now.toLocaleDateString('en-US');
|
|
const time = now.toLocaleTimeString();
|
|
|
|
return `${date} ${time}`;
|
|
}
|
|
|
|
function formatLog(prefixColor, prefix, ...args) {
|
|
let msg = args.join(" ");
|
|
let formattedMessage = `${prefixColor}[${getTimestamp()}] ${prefix}\x1b[0m: ${msg}`;
|
|
console.log(formattedMessage);
|
|
}
|
|
|
|
function backend(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[32m", "Reload Backend Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[32mReload Backend Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
function bot(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[33m", "Reload Bot Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[33mReload Bot Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
function xmpp(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[34m", "Reload Xmpp Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[34mReload Xmpp Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
function error(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[31m", "Reload Error Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[31mReload Error Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
function debug(...args) {
|
|
if (config.bEnableDebugLogs) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[35m", "Reload Debug Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[35mReload Debug Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
function website(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[36m", "Reload Website Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[36mReload Website Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
function AutoRotation(...args) {
|
|
if (config.bEnableAutoRotateDebugLogs) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[36m", "Reload AutoRotation Debug Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[36mReload AutoRotation Debug Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
function checkforupdate(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[33m", "Reload Update Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[33mReload Update Log\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
function autobackendrestart(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[92m", "Reload Auto Backend Restart Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[92mReload Auto Backend Restart\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
function calderaservice(...args) {
|
|
let msg = args.join(" ");
|
|
if (config.bEnableFormattedLogs) {
|
|
formatLog("\x1b[91m", "Caldera Service Log", ...args);
|
|
} else {
|
|
console.log(`\x1b[91mCaldera Service\x1b[0m: ${msg}`);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
backend,
|
|
bot,
|
|
xmpp,
|
|
error,
|
|
debug,
|
|
website,
|
|
AutoRotation,
|
|
checkforupdate,
|
|
autobackendrestart,
|
|
calderaservice
|
|
}; |