JSPM

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

Simple wrapper around Winston to allow for declarative configuaration

Package Exports

  • captains-log

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 (captains-log) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

captains-log

Simple logger for use with Sails, allowing easy custom configuration.

Default log levels

Based on npm's log levels

  • log.silly()
  • log.verbose()
  • log.info()
  • log.debug()
    • (npm calls this level log.http(), but we call it debug. If you use log(), the logger sees this as a call to log.debug())
  • log.warn()
  • log.error()

Custom Examples


/**
 * Using Winston
 * ====================================
 * 
 * Formerly, this module encapsulated Winston, a popular logger
 * by @indexzero and the gals/guys over at Nodejitsu.
 * Recently, we made Winston optional to make CaptainsLog as
 * lightweight as possible and reduce `npm install`/`require()`
 * for its usage in other modules.
 *
 * But Winston is awesome!  And it's a great fit for many apps,
 * giving you granular control over how log output is handled,
 * including sending emails, logging to multiple transports,
 * and other production-time concerns.
 *
 * More info/docs on Winston:
 * https://github.com/flatiron/winston
 * 
 * To use Winston w/ captains-log, do the following:

        var captains = CaptainsLog({
            custom: new (require('winston').Logger)({
                levels     : ...,
                transports : ...
            })
        });
 *
 */

/**
 *
 * Using your own custom logger
 * ====================================
 * 
 * To use a different library, `overrides.custom` must already
 * be instantiated and ready to go with (at minimum) an n-ary `.debug()`
 * method.  i.e. by n-ary, I mean that the following should
 * work (with any # of arguments):
    
        customLogger.debug()
        customLogger.debug('blah')
        customLogger.debug('blah', 'foo')
        customLogger.debug('blah', 'foo', {bar: 'baz'})
        customLogger.debug('blah', 'foo', {bar: 'baz'}, ['a', 3], 2, false);
        // etc.

        // To use a custom logged
        var captains = CaptainsLog({
            custom: customLogger
        });
 *
 */