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",
|
||||
"scripts": {
|
||||
"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",
|
||||
"license": "WTFPL",
|
||||
"dependencies": {
|
||||
"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",
|
||||
"stringify-object": "^3.3.0",
|
||||
"winston": "^2.4.0"
|
||||
"stringify-object": "^3.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { logger } from "./inc/log";
|
||||
import logger from "./inc/log";
|
||||
import { read, cfg } from "./inc/cfg";
|
||||
import { default as config } from "../cfg/config.json";
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { logger } from "../log";
|
||||
import logger from "../log";
|
||||
|
||||
const versions = [
|
||||
"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 { getLevel } from "../../inc/admin";
|
||||
|
@ -1,27 +1,15 @@
|
||||
//const winston = require("winston");
|
||||
import winston from "winston";
|
||||
import fs from "fs";
|
||||
|
||||
const logger = new (winston.Logger)({
|
||||
transports: [
|
||||
new (winston.transports.File)({
|
||||
name: "debug-file",
|
||||
filename: `./logs/${~~(Date.now() / 1000)}_debug.log`,
|
||||
level: "debug"
|
||||
}),
|
||||
new (winston.transports.File)({
|
||||
name: "info-file",
|
||||
filename: `./logs/${~~(Date.now() / 1000)}_info.log`,
|
||||
level: "info"
|
||||
}),
|
||||
new (winston.transports.File)({
|
||||
name: "error-file",
|
||||
filename: `./logs/${~~(Date.now() / 1000)}_error.log`,
|
||||
level: "error"
|
||||
}),
|
||||
new (winston.transports.Console)({
|
||||
level: "info"
|
||||
})
|
||||
]
|
||||
const logger = ["debug", "info", "error"];
|
||||
const logfiles = logger.reduce((a, b) => ({...a, [b]: fs.createWriteStream(`./logs/${~~(Date.now() / 1000)}_${b}.log`)}), {});
|
||||
|
||||
export default new Proxy({}, {
|
||||
get: (_, prop) => (msg, timestamp = new Date().toLocaleString()) =>
|
||||
logger.includes(prop) &&
|
||||
logfiles[prop].write(JSON.stringify({
|
||||
level: prop,
|
||||
message: msg,
|
||||
timestamp: timestamp
|
||||
}) + "\n") &&
|
||||
console.log(timestamp, prop, msg)
|
||||
});
|
||||
|
||||
export { logger };
|
Loading…
Reference in New Issue
Block a user