emigrate/packages/reporter-pino
Joakim Carlstein a4da353d5a feat(cli): add graceful process abort
Using an AbortSignal and Promise.race we abandon running migrations that take longer to complete after the process is aborted than the given abortRespite period
2024-01-22 11:30:06 +01:00
..
src feat(cli): add graceful process abort 2024-01-22 11:30:06 +01:00
CHANGELOG.md chore(release): version packages 2023-12-20 11:24:17 +01:00
package.json chore(release): version packages 2023-12-20 11:24:17 +01:00
README.md docs: include Deno usage instructions in the documentation 2023-12-19 15:40:05 +01:00
tsconfig.json feat(reporter-pino): first version of the package 2023-12-07 14:36:30 +01:00

@emigrate/reporter-pino

A Pino reporter for Emigrate which logs the migration progress using line delimited JSON by default.
Which is great both in production environments and for piping the output to other tools.

Installation

Install the reporter in your project, alongside the Emigrate CLI:

npm install @emigrate/cli @emigrate/reporter-pino
# or
pnpm add @emigrate/cli @emigrate/reporter-pino
# or
yarn add @emigrate/cli @emigrate/reporter-pino
# or
bun add @emigrate/cli @emigrate/reporter-pino

Usage

With default options

Configure the reporter in your emigrate.config.js file:

import reporterPino from '@emigrate/reporter-pino';

export default {
  directory: 'migrations',
  reporter: reporterPino,
};

Or simply:

export default {
  directory: 'migrations',
  reporter: 'pino', // the @emigrate/reporter- prefix is optional
};

Or use the CLI option --reporter (or -r):

emigrate up --reporter pino  # the @emigrate/reporter- prefix is optional

With custom options

Configure the reporter in your emigrate.config.js file:

import { createPinoReporter } from '@emigrate/reporter-pino';

export default {
  directory: 'migrations',
  reporter: createPinoReporter({
    level: 'error', // default is 'info'
    errorKey: 'err', // default is 'error'
  }),
};

The log level can also be set using the LOG_LEVEL environment variable:

LOG_LEVEL=error emigrate up -r pino