1.1.2 • Published 6 years ago

@thetimes/logless v1.1.2

Weekly downloads
21
License
BSD-3-Clause
Repository
github
Last release
6 years ago

logless

Build Status Coverage Status npm version

About

Logless is a lightweight logging library specially crafted for serverless apps.

Install

npm install --save @thetimes/logless

Usage

const loggerFactory = require("@thetimes/logless");

const config = { logLevel: "debug" };

const log = loggerFactory(config, requestID);

log("something's up!");

Using a custom log function

By default logless uses console.log as a log function. But you can define your own by passing it as a config parameter:

const loggerFactory = require("@thetimes/logless");

const myCustomLogFunction = msg => process.stdout.write(msg);

const config = {
  logLevel: "warn",
  logFn: myCustomLogFunction
};

const log = loggerFactory(config, requestID);

log("something's up!");

API

Available log levels: silly|debug|verbose|info|warn|error

factory(config, requestId):

  • config (object): { logLevel, logFn }
    • logLevel (string): the level of logging. All levels below this will not be logged
    • logFn (function): custom log function (if ommited uses console.log)
  • requestId (string): the id of the request being logged

Returns a log function.

log(message):

  • message (string): the message to be logged

Returns void.

Contributing

See the CONTRIBUTING.md for a breakdown of the project

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago