@tsrt/logger
TypeScript icon, indicating that this package has built-in type declarations

0.8.0 • Public • Published

Typescript Reusable Tools: Logger

npm version GitHub license Size Downloads

Common customizable logger built on top of awesome Winston.

Important

Until version 1.0.0 Api should be considered as unstable and may be changed.

So prefer using exact version instead of version with ~ or ^.

Usage

import { Logger } from '@tsrt/logger';

const log = new Logger({
  ...
});

API Reference

export declare class Logger {
  constructor(settings?: ILoggerSettings);

  /** Method to setup/update settings after Logger instance was created. */
  setup(settings?: ILoggerSettings): void;

  debug(message: any, _title?: string): Logger;
  verbose(message: any, _title?: string): Logger;
  info(message: any, _title?: string): Logger;
  warn(message: any, _title?: string): Logger;
  error(message: any, _title?: string): Logger;
}

export declare type LoggerLevels = 'verbose' | 'debug' | 'info' | 'warn' | 'error';

export interface ILoggerSettings {
  /** `Winston` Logger level. @default debug. */
  level?: LoggerLevels;

  /** `Winston` Logger env. @default dev. */
  env?: string;

  /** Whether Logger in `prod` mode. In prod mode there is no beautify options used. @default false. */
  prod?: boolean;

  /** Service name, where `Logger` is used. */
  service?: string;

  /** Whether to add Winston `Console` transport by default. @default true. */
  console?: boolean;

  /** Whether to apply custom format. @default true. */
  customFormat?: boolean;

  /** `Winston` Logger `silent` option. @default false. */
  silent?: boolean;

  /** Other `Winston` options. */
  winstonOptions?: LoggerOptions;
}

License

This project is licensed under the terms of the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i @tsrt/logger

Weekly Downloads

0

Version

0.8.0

License

MIT

Unpacked Size

14.3 kB

Total Files

18

Last publish

Collaborators

  • mopc