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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
Install via npm:
m install abstract-log
or bower:
wer install abstract-log
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.
AbstractLog(
call…
https://github.com/FormidableLabs/abstract-log/issues/3The underlying logger used by the abstraction ideally has:
METHOD
: A method like warn
, info
, error
that takes typically two
arguments.MESSAGE
: A human-readable string, typically the first argument.METADATA
: An structured JS object of metadata that is meant to be outputted
as a JSON line and hopefully programmatically ingested and used later. The
ideal use is any aspect of a log message that is a metric like: database
response time, number of database connections, timestamp, user id, etc.ne(["abstract-log"], function (AbstractLog) {
r log = new AbstractLog();
g.info("Hello world!");
AbstractLog = require("abstract-log");
log = new AbstractLog();
info("Hello world!");
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!");
TODO: Document initialization here? https://github.com/FormidableLabs/abstract-log/issues/3
TODO: Document shimming. https://github.com/FormidableLabs/abstract-log/issues/1
TODO: Document integration with (1) console, (2) bunyan https://github.com/FormidableLabs/abstract-log/issues/2
Please see CONTRIBUTING