JSPM

base-logger

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q30335F
  • License MIT

Add a verbalize logger to your base application.

Package Exports

  • base-logger

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-logger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

base-logger NPM version Build Status

Add a verbalize logger to your base application.

Install

Install with npm:

$ npm install base-logger --save

Usage

Add base-logger to an app.

var logger = require('base-logger');
var app.use(logger());

.logger is now an instance of verbalize on app. All built in logger and mode methods are also exposed on app directly.

// always log this info message
app.info('this is an information message');
// only log this message when app.options.verbose is true
app.verbose.info('this is a verbose information message');
// only log this message when app.options.verbose is false
app.not.verbose.info('this is a not.verbose information message');

Add new logger methods through the .logger

app.logger.addLogger('status');
app.status('status message');
//=> "status message"

Logger methods may pass in a modifier function to stylize the output.

app.logger.addLogger('status', function() {
  return this.stylize('yellow', arguments);
});
app.status('status message');
//=> "status message" <= will be yellow in the console

API

logger

Add verbalize instance to app as .logger. Adds logger and mode methods to the app directly for easy logging. Sets up a default listener to handle log events and write messages to process.stdout

Pass options.defaultListener = false to disable the default listener.

Params

  • options {Objects}: Options used when creating the logger.
  • returns {Function}: plugin function to pass to app.use

Example

var options {
  defaultListener: true
};

app.use(logger(options));
app.verbose.info('info message');
  • log-events: Create custom, chainable logging methods that emit log events when called. | homepage
  • verbalize: A pluggable logging utility with built-in colors, styles, and modes. | homepage

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

Generate readme and API documentation with [verb][]:

$ npm install verb && npm run docs

Or, if [verb][] is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016 Brian Woodward Released under the MIT license.


This file was generated by verb, v0.9.0, on March 06, 2016.