@debugr/typeorm
TypeScript icon, indicating that this package has built-in type declarations

3.0.0-rc.1 • Public • Published

TypeORM plugin for Debugr

This plugin provides a Logger implementation compatible with TypeORM, allowing you to add SQL logging to your tasks.

Installation

npm install --save @debugr/typeorm

Usage

import { 
  Logger, 
  Debugr, 
  LogLevel,
} from '@debugr/core';
import { TypeormLogger } from '@debugr/typeorm';
import { ConsoleLogHandler } from '@debugr/console-handler';
import { SqlConsoleFormatter } from '@debugr/sql-console-formatter';
import { createConnection } from 'typeorm';

const globalContext = {
  applicationName: 'example',
};

// There are all dependent formatters checked and validated.
const debugr = Debugr.create(globalContext, 
  [
    ConsoleLogHandler.create(
      LogLevel.info,
    ),
  ],
  [
    TypeormLogger.create(),
    // Need to add formatter between TypeormLogger and ConsoleLogHandler
    SqlConsoleFormatter.create(),
  ],
);

// inject the plugin into your TypeORM connection options
const connection = await createConnection({
  // ...
  logger: debugr.getPlugin('typeorm'),
});

Readme

Keywords

none

Package Sidebar

Install

npm i @debugr/typeorm

Weekly Downloads

0

Version

3.0.0-rc.1

License

MIT

Unpacked Size

15.3 kB

Total Files

8

Last publish

Collaborators

  • jahudka
  • marek.fiala