base-logger
Add a verbalize logger to your base application.
Last updated 9 years ago by doowb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install base-logger 
SYNC missed versions from official npm registry.

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.

App inherited from base an uses base-option

var App = require('my-app');
var logger = require('base-logger');

create a new app instance setting the logger option to true

var app = new App();
app.option('logger', true);

add the base-logger plugin.

app.use(logger());

.logger is now an instance of verbalize on app. All built in emitter, style, 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.emitter('status');
app.status('status message');
//=> "status message"

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

app.logger.emitter('status', function() {
  return this.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');

Related projects

  • base: base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
  • base-option: Adds a few options methods to base, like option, enable and disable. See the readme… more | homepage
  • 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.

Current Tags

  • 0.1.2                                ...           latest (9 years ago)

3 Versions

  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
Maintainers (2)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (10)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE