@macchiatojs/logger
v0.4.0
Published
Macchiato.js logger based on pino
Downloads
5
Readme
@macchiatojs/logger
Macchiato.js logger based on pino.
Installation
# npm
$ npm install @macchiatojs/logger
# yarn
$ yarn add @macchiatojs/logger
Usage
This is a practical example of how to use.
with Macchiato.js - Express style;
import Macchiato, { Request, Response } from "@macchiatojs/kernel";
import logger from "@macchiatojs/logger";
const app = new Macchiato();
app
.use(logger());
.use((request: Request, response: Response) => {
response.body = "Hello World";
});
app.start(2222);
with Macchiato.js - Koa style;
import Macchiato, { Context } from "@macchiatojs/kernel";
import logger from "@macchiatojs/logger";
const app = new Macchiato();
app
.use(logger());
.use((context: Context) => {
context.response.body = "Hello World";
});
app.start(2222);
with raw Node.js
import http, { IncomingMessage, ServerResponse } from "http";
import { rawLogger } from "@macchiatojs/logger";
const server = http.createServer((request, response) => {
logger()(req, res);
response.statusCode = 200;
response.write("Hello World !");
response.end();
});
server.start(2222);
Note: >
rawLogger
is re-export forpino-http
and You can learn more aboutpino-http
from the official documentation here.