replace winston with own logger
Co-authored-by: jkhsjdhjs
This commit is contained in:
parent
c0ef557f72
commit
6030f51616
@ -5,15 +5,15 @@
|
|||||||
"main": "bot.js",
|
"main": "bot.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node --experimental-modules src/bot.mjs",
|
"start": "node --experimental-modules src/bot.mjs",
|
||||||
"rmlog": "rm logs/*.log || true"
|
"rmlog": "rm logs/*.log || true",
|
||||||
|
"debug": "npm run rmlog ; npm start"
|
||||||
},
|
},
|
||||||
"author": "Flummi & jkhsjdhjs",
|
"author": "Flummi & jkhsjdhjs",
|
||||||
"license": "WTFPL",
|
"license": "WTFPL",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"flumm-fetch-cookies": "git+https://gitfap.de/keinBot/flumm-fetch-cookies",
|
"flumm-fetch-cookies": "git+https://gitfap.de/keinBot/flumm-fetch-cookies",
|
||||||
"long-timeout": "^0.1.1",
|
"cuffeo": "git+https://gitfap.de/keinBot/cuffeo",
|
||||||
"pg-promise": "^7.3.2",
|
"pg-promise": "^7.3.2",
|
||||||
"stringify-object": "^3.3.0",
|
"stringify-object": "^3.3.0"
|
||||||
"winston": "^2.4.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { logger } from "./inc/log";
|
import logger from "./inc/log";
|
||||||
import { read, cfg } from "./inc/cfg";
|
import { read, cfg } from "./inc/cfg";
|
||||||
import { default as config } from "../cfg/config.json";
|
import { default as config } from "../cfg/config.json";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { logger } from "../log";
|
import logger from "../log";
|
||||||
|
|
||||||
const versions = [
|
const versions = [
|
||||||
"AmIRC.1 (8 Bit) for Commodore Amiga 500",
|
"AmIRC.1 (8 Bit) for Commodore Amiga 500",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { logger } from "../log";
|
import logger from "../log";
|
||||||
import { read, cfg } from "../cfg";
|
import { read, cfg } from "../cfg";
|
||||||
|
|
||||||
import { getLevel } from "../../inc/admin";
|
import { getLevel } from "../../inc/admin";
|
||||||
|
@ -1,27 +1,15 @@
|
|||||||
//const winston = require("winston");
|
import fs from "fs";
|
||||||
import winston from "winston";
|
|
||||||
|
|
||||||
const logger = new (winston.Logger)({
|
const logger = ["debug", "info", "error"];
|
||||||
transports: [
|
const logfiles = logger.reduce((a, b) => ({...a, [b]: fs.createWriteStream(`./logs/${~~(Date.now() / 1000)}_${b}.log`)}), {});
|
||||||
new (winston.transports.File)({
|
|
||||||
name: "debug-file",
|
export default new Proxy({}, {
|
||||||
filename: `./logs/${~~(Date.now() / 1000)}_debug.log`,
|
get: (_, prop) => (msg, timestamp = new Date().toLocaleString()) =>
|
||||||
level: "debug"
|
logger.includes(prop) &&
|
||||||
}),
|
logfiles[prop].write(JSON.stringify({
|
||||||
new (winston.transports.File)({
|
level: prop,
|
||||||
name: "info-file",
|
message: msg,
|
||||||
filename: `./logs/${~~(Date.now() / 1000)}_info.log`,
|
timestamp: timestamp
|
||||||
level: "info"
|
}) + "\n") &&
|
||||||
}),
|
console.log(timestamp, prop, msg)
|
||||||
new (winston.transports.File)({
|
|
||||||
name: "error-file",
|
|
||||||
filename: `./logs/${~~(Date.now() / 1000)}_error.log`,
|
|
||||||
level: "error"
|
|
||||||
}),
|
|
||||||
new (winston.transports.Console)({
|
|
||||||
level: "info"
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export { logger };
|
|
Loading…
x
Reference in New Issue
Block a user