Improved logging dev experience
This commit is contained in:
parent
81c620f191
commit
4fae4b40b6
1 changed files with 12 additions and 5 deletions
|
@ -1,13 +1,20 @@
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
import colors, { Color } from "colors"
|
import colors, { Color } from "colors"
|
||||||
import { NextApiRequest } from "next"
|
import { NextApiRequest } from "next"
|
||||||
import { IncomingMessage } from "http"
|
|
||||||
colors.enable()
|
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"],
|
system: ["SYSTEM", "green"],
|
||||||
"info.green": ["INFO", "green"],
|
infoGreen: ["INFO", "green"],
|
||||||
"info.cyan": ["INFO", "cyan"],
|
infoCyan: ["INFO", "cyan"],
|
||||||
debug: ["Debug", "grey"],
|
debug: ["Debug", "grey"],
|
||||||
post: ["Post", "white"],
|
post: ["Post", "white"],
|
||||||
warn: ["WARN", "yellow"],
|
warn: ["WARN", "yellow"],
|
||||||
|
@ -22,7 +29,7 @@ let started: boolean = false
|
||||||
async function logStartup() {
|
async function logStartup() {
|
||||||
await fs.promises.stat("log").catch(async () => {
|
await fs.promises.stat("log").catch(async () => {
|
||||||
await fs.promises.mkdir("log")
|
await fs.promises.mkdir("log")
|
||||||
await logging(`Created 'log' Folder.`, ["info.cyan", "system"])
|
await logging(`Created 'log' Folder.`, ["infoCyan", "system"])
|
||||||
})
|
})
|
||||||
started = true
|
started = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue