0.1.1 • Published 4 years ago

@node-ts/logger-winston v0.1.1

Weekly downloads
77
License
MIT
Repository
-
Last release
4 years ago

@node-ts/logger-winston

A Winston implementation for logger.

Usage

Install the package and its dependenceis

npm i @node-ts/logger-winston @node-ts/logger-core

Load the modules during application startup in inversify:

import { Container } from 'inversify'
import { LoggerModule } from '@node-ts/logger-core'
import { WinstonModule } from '@node-ts/logger-winston'

// ...

const container = new Container()
container.load(new LoggerModule())
container.load(new WinstonModule())

Custom Configuration

To configure the winston logger instances, provide your own WinstonConfiguration implementation, ie:

@injectable()
export class CustomWinstonConfiguration implements WinstonConfiguration {
  getConfiguration (loggerName: string): winston.LoggerOptions {
    return {
      defaultMeta: { loggerName }
      // etc
    }
  }
}

Then to use it, rebind the WINSTON_SYMBOLS.WinstonConfiguration symbol on your application startup:

import { ContainerModule } from 'inversify'
import { CustomWinstonConfiguration } from './custom-winston-configuration'
import { WINSTON_SYMBOLS } from '@node-ts/logger-winston'

export class ApplicationModule extends ContainerModule {
  constructor () {
    super((_, __, ___, rebind) => {
      rebind(WINSTON_SYMBOLS.WinstonConfiguration).to(CustomWinstonConfiguration)
    })
  }
}
0.1.1

4 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago