Namespaced Console Logger
Minimal namespaced stdout / stderr logger with a timestamp for the browser and Node.js.
The logger satisfies three requirements below and attempts to do nothing else:
- Is small: has no dependencies & <50 loc (for the browser)
- Has a timestamp
- Has a namespace
Example output:
2015-08-10T20:09:20.526Z (namespace) INFO: Hello world!
Usage
; const loggers = ;const logger = loggers; logger;
createLoggers()
takes a minimum logginglevel
, which is one of:['info', 'warn', 'error']
and defaults toinfo
. For example if you selectwarn
, allinfo
logs will be ignored.warn
anderror
logs will be displayed.
Support for formatting and arbitrary metadata
; const loggers = ;const logger = loggers; //2015-08-10T20:09:20.526Z machinename 3 (namespace) INFO: Hello world!logger;