Skip to content
📄 A multi channel logger written in TypeScript.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Travis build: 181 v5.0.0 [ci skip] Mar 10, 2019
sh chore: fix repo Nov 27, 2017
src feat: Add time field support to replace original startTime by a custo… Apr 22, 2019
tasks/semantic fix: Update stack Mar 10, 2019
test fix: Update stack Mar 10, 2019
.gflowrc
.gitignore
.lintstagedrc fix: Update stack Mar 10, 2019
.npmignore Fix compilation Nov 27, 2016
.nycrc Merge fix/update-tsconfig Mar 10, 2019
.prettierignore fix: Update stack Mar 10, 2019
.prettierrc fix: Update stack Mar 10, 2019
.travis.yml
CONTRIBUTING.md docs: Improve documentation Aug 3, 2017
ISSUE_TEMPLATE.md docs: Improve documentation Aug 3, 2017
LICENSE feat(refacto): Add appenders, layouts and multiple loggings output Jun 25, 2017
PULL_REQUEST_TEMPLATE.md chore: remove node v4 and v5 Nov 27, 2017
package.json Travis CI build: 193 v5.1.0 [ci skip] Apr 22, 2019
readme.md fix: Update git information and unit test Mar 10, 2019
tsconfig.compile.json fix: Update git information and unit test Mar 10, 2019
tsconfig.json fix: Log dependency Mar 10, 2019
tslint.json feat(refacto): Add appenders, layouts and multiple loggings output Jun 25, 2017
yarn.lock chore: add gflow Mar 10, 2019

readme.md

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
npm install source-map-support

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: ","
        }
    })
You can’t perform that action at this time.