Socket
Book a DemoInstallSign in
Socket

@exotjs/logger

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@exotjs/logger

Pino-based logger plugin for Exot.

unpublished
latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Logger plugin for Exot

A logger plugin for Exot built on top of Pino.

Usage

The pino logger is available as context.log in the route handler:

import { Exot } from '@exotjs/exot';
import { logger } from '@exotjs/logger';

new Exot()
  .use(logger({
    bindings: (ctx) => {
      return {
        requestId: ctx.requestId,
      };
    },
    logRequests: true,
    pinoOptions: {
      // configure pino here...
    },
  }))

  .use(({ log }) => {
    log.info('Executing middleware...');
  })

  .get('/', ({ log }) => {
    log.info('Sending greetings...');

    return 'Hi';
  })

  .listen(3000);

Usage outside of routes

The main pino instance is available as a decorator on the main Exot instance:

exot.decorators.log.info('log message...');

Configuration

bindings: (ctx: Context) => Record<string, uknown> - use this function to bind custom "child bindings" for each request (defaults to: { requestId }).

logRequests: boolean - whether to automatically log request information (method, url, headers, remoteAddress).

pinoOptions: PinoOptions - see Pino docs.

Credits

Pino

License

MIT

Keywords

exot

FAQs

Package last updated on 24 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts