JSPM

  • Created
  • Published
  • Downloads 2210
  • Score
    100M100P100Q113200F
  • License MIT

A multi channel logger written in TypeScript.

Package Exports

  • ts-log-debug
  • ts-log-debug/lib/layouts/utils/colorizeUtils

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ts-log-debug) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

TsLogDebug

Build Status Coverage Status TypeScript Package Quality npm version Dependencies img img Known Vulnerabilities

A multi channel logger written in TypeScript.

Features

  • Colored console logging to stdout or stderr,
  • File appender, with configurable log rolling based on file size or date
  • Configurable log message layout/patterns
  • Different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)

Please refer to the documentation for more details.

Installation

npm install -g typescript
npm install ts-log-debug

Breaking change 3.x

Since v3.x, the logger is completely rewritten to support new features. This new version is inspired by the excellent project log4js.

Quick start

Minimalist version:

import {$log} from "ts-log-debug";
$log.level = "debug";
$log.name = "APP";

$log.debug("Some debug messages");

Will be procude the following log output:

[2017-06-17 11:43:37.987] [DEBUG] [APP] - Some debug messages

Create your custom logger:

import {Logger} from "ts-log-debug";

const logger = new Logger("loggerName");
logger.appenders
    .push({
        type: "stdout",
        levels: ["debug", "info", "trace"]
    })
    .push({
        type: "stderr",
        levels: ["fatal", "error", "warn"],
        layout: {
          type: "pattern",
          pattern: "%d %p %c %X{user} %m%n"
        }
    })
    .push({
        type: "file",
        filename: `${__dirname}/app.log`,
        layout:{
            type: "json",
            separator: ","
        }
    })