@hackforplay/log
A simple, cross environment logger written in TypeScript.
Last updated 10 months ago by teramotodaiki .
MIT · Original npm · Tarball · package.json
$ cnpm install @hackforplay/log 
SYNC missed versions from official npm registry.

@hackforplay/log

Actions Status npm latest version

This is a simple logger written in TypeScript. Created for @hackforplay/sandbox and @hackforplay/common.

Type definition is ready to import! d.ts is included in this package.

Install

npm install @hackforplay/log

How to use

import { createLogger } from '@hackforplay/log';

const logger = createLogger();

// Show all logs
logger.subscribe(console.info);

// Add a new line
const log = logger.log;
log('Hello World!');

Sharing loggers between independent libraries

As you use createLogger(), the shared reference will be injected in global. e.g. window in browsers or self in the Node.js.

import { createLogger } from '@hackforplay/log';

const loggerA = createLogger();
const loggerB = createLogger();
console.log(loggerA === loggerB); // true

const loggerC = createLogger('You can use different reference with key string');
console.log(loggerA === loggerC); // false

// Yes, This is global injection :P
console.log(
  loggerC === window['You can use different reference with key string']
); // true

If you hate this way, you can use constructor. This way DO NOT global injection.

import { Logger } from '@hackforplay/log';

const logger = new Logger();

// Show all logs
logger.subscribe(console.info);

// Add a new line
const log = logger.log;
log('Hello World!');

Current Tags

  • 1.3.5                                ...           latest (10 months ago)

11 Versions

  • 1.3.5                                ...           10 months ago
  • 1.3.4                                ...           10 months ago
  • 1.3.3                                ...           10 months ago
  • 1.3.2                                ...           10 months ago
  • 1.3.1                                ...           10 months ago
  • 1.3.0                                ...           10 months ago
  • 1.2.0                                ...           10 months ago
  • 1.1.0                                ...           10 months ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 1.0.2                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |