typed-logging
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Minimal leightweight logging for TypeScript and JavaScript.

Log levels trace, debug, info, warn, error, silent.

Features

  • Displays the correct line numbers in the browser.

  • Supports different log levels, if the level is set to warn, only log.warn and log.error are executed. Other messages like log.info stay silent.

  • Log methods gracefully fall back to simpler console logging methods if they are not supported in the environment. E.g. calls to log.debug() go to console.debug() if possible, otherwise to console.log().

  • Plugins may be used to transform the logging output, e.g. to prefix all messages with a timestamp.

Installation

Install node.js and then run npm install --save typed-logging or yarn add typed-logging to add typed-logging as a dependency.

Usage

And then use it

// when using TypeScript or ES6 modules
import log rom 'typed-logging';
 
// when using CommonJS
const { log } = require('typed-logging');
 
log.info('info')

In the browser, you can also directly use it as an UMD package from unpkg:

<script src="https://unpkg.com/typed-logging/dist/typed-logging.umd.js"></script>

This exposes the class window.Logger and the default instance window.log.

Package Sidebar

Install

npm i typed-logging

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

27.7 kB

Total Files

9

Last publish

Collaborators

  • marcw136