@thetimes/logless
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @thetimes/logless

Weekly Downloads

17

Version

1.1.2

License

BSD-3-Clause

Unpacked Size

10.8 kB

Total Files

8

Last publish

Collaborators

  • tnlweb
  • marcincuber
  • newsuk