UNPKG

@opengis/fastify-table

Version:

core-plugins

26 lines (25 loc) 1.11 kB
import { rename } from "node:fs/promises"; import logger from "../../../plugins/logger/getLogger.js"; export default async function testLog(request, reply) { logger.metrics("logger-test"); logger.file("logger-test", { code: 200, start: true }); if (request.query?.rejection) { rename("/data/local/test", "/data/local/test.txt"); } if (request.query?.awaitRejection) { await rename("/data/local/test", "/data/local/test.txt"); } if (request.query?.throw) { throw new Error("444"); } logger.trace({ data: 111, msg: "string trace log1" }, request); logger.debug({ data: 111, msg: "string debug log1" }, request); logger.warn({ data: 111, msg: "string warn log1" }, request); logger.fatal({ data: 111, msg: "string fatal log1" }, request); logger.info({ data: 111, msg: "string info log1" }, request); logger.info("string info log1", request); logger.info("string info log1"); logger.info({ data: 111, msg: "string info log1" }); logger.error(new Error("222"), request); return reply.status(200).send({ root: true }); }