Skip to content

Latest commit

 

History

History
102 lines (76 loc) · 1.54 KB

MIGRATION.md

File metadata and controls

102 lines (76 loc) · 1.54 KB

Migration Guide

v0.0.11 to v0.0.12

Automatic onResponse logging by default

Use:

import { logger, createPinoLogger } from '@bogeychan/elysia-logger';

app.use(
  logger({
    autoLogging: false
  })
);

const log = createPinoLogger();

app.use(
  log.into({
    autoLogging: false
  })
);

Instead of:

import { logger, createPinoLogger } from '@bogeychan/elysia-logger';

app.use(logger());

const log = createPinoLogger();

app.use(log.into());

v0.0.9 to v0.0.10

Infer the Elysia Context

Use:

import { type InferContext } from '@bogeychan/elysia-logger';

app.use(
  logger({
    customProps(ctx: InferContext<typeof app>) {
      return {};
    }
  })
);

Instead of:

import {
  type ElysiaContextForInstance,
  type InferElysiaInstance
} from '@bogeychan/elysia-logger';

app.use(
  logger({
    customProps(
      ctx: ElysiaContextForInstance<InferElysiaInstance<typeof app>>
    ) {
      return {};
    }
  })
);

The contextKeyName option is obsolete

You can learn more about this in the Elysia's 0.7 blog

Use:

app
  .use(logger().derive(({ log, ...rest }) => ({ myLogger: log, ...rest })))
  .get('/', (ctx) => {
    ctx.myLogger.info(ctx.request, 'Request');
  });

Instead of:

app
  .use(
    logger({
      contextKeyName: 'myLogger'
    })
  )
  .get('/', (ctx) => {
    ctx.myLogger.info(ctx.request, 'Request');
  });