-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Given this logger...
import { Logestic, chalk } from "logestic";
// exports a Logestic plugin instance
export const logger = new Logestic({ showLevel: true })
.use(["time", "method", "path", "status", "duration"])
.format({
// onRequest({ time, method, path }) {
// const grayTime = chalk.gray(`${time!.toISOString()}`);
// const methodPath = chalk.cyan(`${method} ${path}`);
// return `[${grayTime}] 🟢 ${methodPath}`;
// },
onSuccess({ time, method, path, status, duration }) {
const grayTime = chalk.gray(`${time!.toISOString()}`);
const methodPath = chalk.cyan(`${method} ${path}`);
let statusColor = chalk.white;
if (200 <= status && status < 300) statusColor = chalk.green;
if (400 <= status && status < 500) statusColor = chalk.yellow;
if (500 <= status) statusColor = chalk.red;
const durationInMsecs = chalk.magenta(`${(duration ?? 0n) / 1000n}`);
return `[${grayTime}] 🛑 ${methodPath} | ${statusColor(status)} | ${durationInMsecs} ms\n`;
},
onFailure({ request, error, code, datetime }) {
const log = chalk.red(`[${datetime.toISOString()}]: ${request.method} ${request.url} | ERROR | ${code}`);
return `${log}\n${error}`;
},
});
I get undefined errors on time
. If I replace the time
reference in the string interpolation with (new Date())
then I get undefined
on every argument in the onSuccess
console logs. I have determined that this behavior change was introduced in 1.0.1.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers