diff --git a/README.md b/README.md index 54308e7..3ba4c5a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # Whistlepunk -[![Version npm](https://img.shields.io/npm/v/whistlepunk.svg?style=flat)](https://www.npmjs.com/package/whistlepunk) -[![npm Downloads](https://img.shields.io/npm/dm/whistlepunk.svg?style=flat)](https://www.npmjs.com/package/whistlepunk) -[![Dependencies](https://img.shields.io/david/LeanKit-Labs/whistlepunk.svg?style=flat)](https://david-dm.org/LeanKit-Labs/whistlepunk) +[![Version npm](https://img.shields.io/npm/v/payapi-whistlepunk.svg?style=flat)](https://www.npmjs.com/package/payapi-whistlepunk) +[![npm Downloads](https://img.shields.io/npm/dm/payapi-whistlepunk.svg?style=flat)](https://www.npmjs.com/package/payapi-whistlepunk) +[![Dependencies](https://david-dm.org/payapi/whistlepunk/status.svg?style=flat)](https://david-dm.org/payapi/whistlepunk) > *noun* - a lumberjack who operates the signal wire running to a donkey engine whistle. +## NOTE + +This repository is a fork of https://github.com/LeanKit-Labs/whistlepunk. It was forked solely to apply dependency upgrades and to release an npm module containing the upgraded dependencies. + ## What Is It? Logging.....sigh. It's necessary, but often intrusive, heavy-handed and cumbersome...or it's anemic and fails to satisfy the needs of Ops and Developers. Whistlepunk doesn't care about what logging tools you love to use. It just cares that it needs to "blow the whistle" (i.e. - indicate something should be logged). You can plug your favorite logging tool into whistlepunk by writing an adapter for it (which consists of susbcribing to the postal "log" channel and writing the published log messages to your preferred logging library). At LeanKit, we're using [debug]() a lot (during development) and then standard out for production logs - so whistlepunk has two adapters (currently) built-in. @@ -17,20 +21,20 @@ var postal = require("postal"); var whistlepunk = require("whistlepunk"); var config = { - adapters: { - stdOut: { - level: 4, - bailIfDebug: true, // disables stdOut if DEBUG=* is in play - timestamp: { - local: true, // defaults to UTC - format: "MMM-D-YYYY hh:mm:ss A" // ex: Jan 1, 2015 10:15:20 AM - }, - topic: "#", // default topic - }, - "debug": { - level: 4 - } - } + adapters: { + stdOut: { + level: 4, + bailIfDebug: true, // disables stdOut if DEBUG=* is in play + timestamp: { + local: true, // defaults to UTC + format: "MMM-D-YYYY hh:mm:ss A" // ex: Jan 1, 2015 10:15:20 AM + }, + topic: "#", // default topic + }, + "debug": { + level: 4 + } + } }; var loggerFactory = whistlepunk(postal, config); @@ -50,20 +54,20 @@ This also supports use cases where you may want to change log configuration duri var whistlepunk = require("whistlepunk").log; var config = { - adapters: { - stdOut: { - level: 5, - bailIfDebug: true, // disables stdOut if DEBUG=* is in play - timestamp: { - local: true, // defaults to UTC - format: "MMM-D-YYYY hh:mm:ss A" // ex: Jan 1, 2015 10:15:20 AM - }, - topic: "#", // default topic - }, - "debug": { - level: 5 - } - } + adapters: { + stdOut: { + level: 5, + bailIfDebug: true, // disables stdOut if DEBUG=* is in play + timestamp: { + local: true, // defaults to UTC + format: "MMM-D-YYYY hh:mm:ss A" // ex: Jan 1, 2015 10:15:20 AM + }, + topic: "#", // default topic + }, + "debug": { + level: 5 + } + } }; var logger = whistlepunk( "my.topic" ); @@ -100,11 +104,11 @@ Be aware that when calling `reset` on a log, all adapter subscriptions that matc __example topics__ ```javascript - topic: "#" // will subscribe to all logs - topic: "autohost.#" // will subscribe to all autohost loggers - topic: "#.errors" // would subscribe to any logger with a namespace ending in "error" - topic: "myApp.#,autohost.#" // subscribes to `myApp.#` and `autohost.#` - topic: [ "myApp.#", "autohost.#" ] // same as above but + topic: "#" // will subscribe to all logs + topic: "autohost.#" // will subscribe to all autohost loggers + topic: "#.errors" // would subscribe to any logger with a namespace ending in "error" + topic: "myApp.#,autohost.#" // subscribes to `myApp.#` and `autohost.#` + topic: [ "myApp.#", "autohost.#" ] // same as above but ``` ### Timestamps @@ -116,10 +120,10 @@ Adapters should support the `timestamp` property in their configuration. To lear The timestamp property has the following properties: ```javascript - { - local: false, // default setting - format: "YYYY-MM-DDTHH:mm:ss.SSSZ" // default setting - } + { + local: false, // default setting + format: "YYYY-MM-DDTHH:mm:ss.SSSZ" // default setting + } ``` #### Adapter Authors @@ -141,18 +145,18 @@ var postal = require("postal"); var whistlepunk = require("whistlepunk"); var config = { - adapters: { - stdOut: { - level: 4, - bailIfDebug: true // disables stdOut if DEBUG=* is in play - }, - "debug": { - level: 4 - }, - autohost: { - level: 4 - } - } + adapters: { + stdOut: { + level: 4, + bailIfDebug: true // disables stdOut if DEBUG=* is in play + }, + "debug": { + level: 4 + }, + autohost: { + level: 4 + } + } }; // assuming autohost instance is assigned to a "host" variable var loggerFactory = whistlepunk(postal, config, host.fount); @@ -179,20 +183,20 @@ Optionally, your adapter module can: var debug = require( "debug" ); var namespaces = {}; var debugAdapter = { - onLog: function( data ) { - var debugNs = namespaces[ data.namespace ]; - if ( !debugNs ) { - debugNs = namespaces[ data.namespace ] = debug( data.namespace ); - } - debugNs( data.type, data.msg ); - } + onLog: function( data ) { + var debugNs = namespaces[ data.namespace ]; + if ( !debugNs ) { + debugNs = namespaces[ data.namespace ] = debug( data.namespace ); + } + debugNs( data.type, data.msg ); + } }; // factory method returns the same instance every time // this allows whistlepunk to prevent creating duplicate subscriptions // which would cause duplicate log entries module.exports = function( config ) { - return debugAdapter; + return debugAdapter; }; ``` @@ -202,31 +206,31 @@ var noOpAdapter = { onLog: function() {} }; var adapter; function createAhAdapter( fount ) { - var host; - - return { - // whistlepunk will call this when present - // and cache log messages for this adapter - // until the promise resolves - init: function() { - return fount.resolve( "ah" ) - .then( function( _host ) { - host = _host; - } ); - }, - onLog: function( data ) { - if ( host && host.notifyClients ) { - host.notifyClients( data.type, data ); - } - } - }; + var host; + + return { + // whistlepunk will call this when present + // and cache log messages for this adapter + // until the promise resolves + init: function() { + return fount.resolve( "ah" ) + .then( function( _host ) { + host = _host; + } ); + }, + onLog: function( data ) { + if ( host && host.notifyClients ) { + host.notifyClients( data.type, data ); + } + } + }; } // because need fount to get a handle to the // autohost instance, return a no-op adapter // if it's missing module.exports = function( config, formatter, fount ) { - adapter = adapter || ( fount ? createAhAdapter( fount ) : noOpAdapter ); - return adapter; + adapter = adapter || ( fount ? createAhAdapter( fount ) : noOpAdapter ); + return adapter; }; ``` diff --git a/package.json b/package.json index 0c6e6b1..c4aa62d 100644 --- a/package.json +++ b/package.json @@ -1,39 +1,21 @@ { - "name": "whistlepunk", - "version": "0.3.3", - "homepage": "https://github.com/LeanKit-Labs/whistlepunk", - "description": "Logging abstraction that signals any enabled adapters of a new log message.", - "author": "LeanKit", + "name": "payapi-whistlepunk", + "version": "0.3.4", + "homepage": "https://github.com/payapi/whistlepunk", + "description": "Logging abstraction that signals any enabled adapters of a new log message. Forked from https://github.com/LeanKit-Labs/whistlepunk for making security upgrades to dependencies. Please use the original one once they have merged the PR's and created a release.", + "author": "payapi.io", "repository": { "type": "git", - "url": "git://github.com/LeanKit-Labs/whistlepunk.git" + "url": "git://github.com/payapi/whistlepunk.git" }, "publishConfig": { "registry": "https://registry.npmjs.org/" }, "contributors": [ { - "name": "Jim Cowart", - "email": "jim@ifandelse.com", - "url": "http://ifandelse.com" - }, - { - "name": "Alex Robson", - "email": "WhyNotJustComment@OnMyBlog.com", - "url": "http://nerdventure.io/" - }, - { - "name": "Brian Edgerton", - "url": "https://github.com/brianedgerton" - }, - { - "name": "Derick Bailey", - "url": "http://derickbailey.com", - "email": "derickbailey@gmail.com" - }, - { - "name": "Michael Tuttle", - "url": "https://github.com/openam" + "name": "Marko Haapala", + "email": "marko@payapi.io", + "url": "https://es.linkedin.com/in/markohaapala" } ], "keywords": [ @@ -52,7 +34,7 @@ "debug": "2.2.0", "lodash": "3.x", "machina": "1.x", - "moment": "2.10.2", + "moment": "2.17.1", "when": "3.x", "postal": "1.x" },