koa-pino-logger
2024年12月10日
一、认识
二、准备
npm install koa-pino-logger
三、语法
const Koa = require("koa");
const KoaRouter = require("koa-router");
const pino = require('koa-pino-logger')();
const port = 3000;
const app = new Koa();
const router = new KoaRouter();
app.use(pino);
router.get("/", (ctx)=>{
ctx.log.info("嘻嘻哈哈");
ctx.body = {
code: 200,
message: "成功!"
}
});
app.use(router.routes());
app.listen(port, ()=>{
console.log(`Service is running ${port}`)
});