24 lines
738 B
JavaScript
24 lines
738 B
JavaScript
|
import colors from "colors"
|
||
|
import { createWriteStream } from "fs"
|
||
|
|
||
|
const fileLog = createWriteStream('maintenance-bot.log', { encoding: "utf8", flags: "a" })
|
||
|
|
||
|
function makeDate() {
|
||
|
const now = new Date(Date.now())
|
||
|
const date = now.toLocaleDateString("en-GB", { hour12: false })
|
||
|
const time = now.toLocaleTimeString("en-GB", { hour12: false })
|
||
|
|
||
|
return `(${date} -- ${time})`
|
||
|
}
|
||
|
|
||
|
export default function getLogger(prefix, color) {
|
||
|
const clr = colors[color] ?? colors[red]
|
||
|
|
||
|
return function (...args) {
|
||
|
fileLog.write(`[${prefix}] -- ${makeDate()}:\n`)
|
||
|
fileLog.write(`${args.join(", ")}\n\n`)
|
||
|
|
||
|
console.log(`${clr(prefix)} ${colors.grey(makeDate())}:`)
|
||
|
console.log(...args, "\n")
|
||
|
}
|
||
|
}
|