Improved logging dev experience

This commit is contained in:
aronmal 2023-04-05 01:20:57 +02:00
parent 81c620f191
commit 4fae4b40b6
Signed by: aronmal
GPG key ID: 816B7707426FC612

View file

@ -1,13 +1,20 @@
import fs from "fs"
import colors, { Color } from "colors"
import { NextApiRequest } from "next"
import { IncomingMessage } from "http"
colors.enable()
const loggingTemplates: { [key: string]: LoggingType } = {
const loggingTemplates: {
system: LoggingType
infoGreen: LoggingType
infoCyan: LoggingType
debug: LoggingType
post: LoggingType
warn: LoggingType
error: LoggingType
} = {
system: ["SYSTEM", "green"],
"info.green": ["INFO", "green"],
"info.cyan": ["INFO", "cyan"],
infoGreen: ["INFO", "green"],
infoCyan: ["INFO", "cyan"],
debug: ["Debug", "grey"],
post: ["Post", "white"],
warn: ["WARN", "yellow"],
@ -22,7 +29,7 @@ let started: boolean = false
async function logStartup() {
await fs.promises.stat("log").catch(async () => {
await fs.promises.mkdir("log")
await logging(`Created 'log' Folder.`, ["info.cyan", "system"])
await logging(`Created 'log' Folder.`, ["infoCyan", "system"])
})
started = true
}