FormidableLabs/abstract-log

Name: abstract-log

Owner: Formidable

Description: A micro logging wrapper for shims, logging frameworks, console logs, etc.

Created: 2015-08-01 23:43:02.0

Updated: 2017-11-08 17:49:08.0

Pushed: 2015-08-04 00:01:47.0

Homepage: null

Size: 132

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Travis Status

Abstract Log

An micro log wrapper to implement production shims, loggers, etc.

The primary use case for this wrapper is for a project that needs to do some logging but doesn't want to take dependencies on a specific logger (like Bunyan, Winston, Good, etc.) or assume use in a specific environment (browser, Node.js, both etc.). And it is easily configured as a straight shim to do nothing in the most lightweight manner possible.

As an example, the main impetus for the creation of AbstractLog is for small React components that have no other dependencies, want to log specific information in the browser and in Node.js on the server, and leave the actual implementation of the logger up the consumer of the library code.

Installation

Install via npm:

m install abstract-log

or bower:

wer install abstract-log
Usage

Import the AbstractLog class into your code (via AMD, CommonJS, etc) and use as a configurable logger. The basic abstraction is:

log = new AbstractLog(OPTIONS);

METHOD(MESSAGE_STRING, METADATA_OBJECT);  // Abstraction
warn("My message", { an: "object" });     // Example

The instance of an AbstractLog requires an OPTIONS object that defines the actual methods available for the logger.

The underlying logger used by the abstraction ideally has:

AMD
ne(["abstract-log"], function (AbstractLog) {
r log = new AbstractLog();
g.info("Hello world!");

CommonJS
AbstractLog = require("abstract-log");
log = new AbstractLog();
info("Hello world!");
VanillaJS

In your HTML:

 Option One: Minified -->
ipt src="PATH/TO/abstract-log/dist/abstract-log.min.js"></script>

 Option Two: Raw source -->
ipt src="PATH/TO/abstract-log/abstract-log.js"></script>

In your JS:

log = new window.AbstractLog();
info("Hello world!");
Build Integration
Contributing

Please see CONTRIBUTING


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.