0.1.2 • Published 4 years ago

@elderbyte/ts-logger v0.1.2

Weekly downloads
130
License
MIT
Repository
github
Last release
4 years ago

CI Status npm version

TypeScript logger

A simple but highly customizable TypeScript logger.

  • Bundled with rollup in es5 format.
  • Configure once - if used in libraries you consume, the main app can configure the logger globally
  • Works well with other frameworks.
  • Angular 5 Apps and AOT compilation is supported.

Installation

Install via NPM: npm i --save @elderbyte/ts-logger

Usage

import {LoggerFactory} from '@elderbyte/ts-logger';

class MyClass {

  private logger = LoggerFactory.getLogger('MyClass');

  public myMethod(): void {
    this.logger.info('You invoked myMethod!');
  }
}

Will result in a log like:

2018-01-11T14:28:49.401Z DEBUG MyClass You invoked myMethod!

Browser which support coloring will also have different colors depending on the log level.

Configuration

Configuration is provided with default values to support out of the box working logging expirience.

Each LoggerFactory instance can be configured independently. There is however a global, static default instance and its recommended to use this accross all your projects and libraries. This will allow to configure the logger on a central place (such as your main app).

You can configure the max log level, custom appenders and message formatter. All of these are optional.

LoggerFactory.getDefaultConfiguration()
      .withMaxLevel(LogLevel.Trace) // Defaults to Info
      .withAppender(new ConsoleLogAppender()) // Same as default
      .withFormatter(new SimpleMessageFormatter()) // Same as default
0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago