├── .gitignore ├── .jscsrc ├── .jshintrc ├── .travis.yml ├── README.md ├── index.js ├── newrelicHelper.js ├── package-lock.json ├── package.json └── test ├── newrelic-winston.js ├── newrelicHelper.js └── stubs ├── newrelic.js └── newrelicHelper.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .svn 3 | npm-debug.log -------------------------------------------------------------------------------- /.jscsrc: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "fileExtensions": [ 4 | ".js", 5 | "jscs" 6 | ], 7 | 8 | "requireParenthesesAroundIIFE": true, 9 | "maximumLineLength": 120, 10 | "validateIndentation": 2, 11 | "disallowTrailingComma": true, 12 | "requireCommaBeforeLineBreak": true, 13 | "disallowYodaConditions" : true, 14 | "disallowSpacesInsideObjectBrackets": null, 15 | "safeContextKeyword": "self", 16 | "disallowEmptyBlocks": true, 17 | "disallowMixedSpacesAndTabs": true, 18 | "disallowMultipleLineBreaks": true, 19 | "disallowMultipleSpaces": true, 20 | "disallowNewlineBeforeBlockStatements": true, 21 | "disallowSpaceAfterObjectKeys": true, 22 | "disallowSpacesInCallExpression": true, 23 | "disallowTrailingWhitespace": true, 24 | "requireBlocksOnNewline": true, 25 | "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties", 26 | "requireCapitalizedComments": true, 27 | "requireCapitalizedConstructors": true, 28 | "requireLineBreakAfterVariableAssignment": true, 29 | "requireLineFeedAtFileEnd": true, 30 | "requireSemicolons": true, 31 | "requireSpaceBeforeBlockStatements": true, 32 | "requireSpaceBeforeObjectValues": true, 33 | "requireSpaceBetweenArguments": true, 34 | "requireSpacesInForStatement": true, 35 | "validateQuoteMarks": "'", 36 | 37 | 38 | //"disallowPaddingNewlinesInBlocks": true, 39 | 40 | "requireCurlyBraces": [ 41 | "if", 42 | "else", 43 | "for", 44 | "while", 45 | "do", 46 | "try", 47 | "catch", 48 | "case" 49 | ], 50 | 51 | "requireSpaceAfterBinaryOperators": [ 52 | "=", 53 | ",", 54 | "+", 55 | "-", 56 | "/", 57 | "*", 58 | "==", 59 | "===", 60 | "!=", 61 | "!==" 62 | ], 63 | 64 | "requireSpaceBeforeBinaryOperators": [ 65 | "=", 66 | "+", 67 | "-", 68 | "/", 69 | "*", 70 | "==", 71 | "===", 72 | "!=", 73 | "!==" 74 | ], 75 | 76 | "disallowSpaceAfterPrefixUnaryOperators": [ 77 | "++", 78 | "--", 79 | "+", 80 | "-", 81 | "~", 82 | "!" 83 | ], 84 | 85 | "disallowSpacesInAnonymousFunctionExpression": { 86 | "beforeOpeningRoundBrace": true 87 | }, 88 | 89 | "disallowSpacesInFunctionDeclaration": { 90 | "beforeOpeningRoundBrace": true 91 | }, 92 | 93 | "disallowSpacesInFunctionExpression": { 94 | "beforeOpeningRoundBrace": true 95 | }, 96 | 97 | "disallowSpacesInFunction": { 98 | "beforeOpeningRoundBrace": true 99 | }, 100 | 101 | "disallowSpacesInNamedFunctionExpression": { 102 | "beforeOpeningRoundBrace": true 103 | }, 104 | 105 | "requireSpacesInAnonymousFunctionExpression": { 106 | "beforeOpeningCurlyBrace": true 107 | }, 108 | 109 | "requireSpacesInFunctionDeclaration": { 110 | "beforeOpeningCurlyBrace": true 111 | }, 112 | 113 | "requireSpacesInFunctionExpression": { 114 | "beforeOpeningCurlyBrace": true 115 | }, 116 | 117 | "requireSpacesInFunction": { 118 | "beforeOpeningCurlyBrace": true 119 | }, 120 | 121 | "requireSpacesInNamedFunctionExpression": { 122 | "beforeOpeningCurlyBrace": true 123 | }, 124 | 125 | "disallowSpaceBeforeBinaryOperators": [ 126 | "," 127 | ], 128 | 129 | "disallowSpaceBeforePostfixUnaryOperators": [ 130 | "++", 131 | "--" 132 | ], 133 | 134 | "disallowOperatorBeforeLineBreak": [ 135 | "+", 136 | "." 137 | ], 138 | 139 | "disallowKeywordsOnNewLine": [ 140 | "else" 141 | ], 142 | 143 | "requireSpaceBeforeKeywords" : [ 144 | "else", 145 | "while", 146 | "catch" 147 | ], 148 | 149 | "disallowKeywords": [ 150 | "with", 151 | "class" 152 | ], 153 | 154 | "disallowImplicitTypeConversion": [ 155 | "string" 156 | ], 157 | 158 | "excludeFiles": [ 159 | "node_modules/**", 160 | "stats/**" 161 | ], 162 | 163 | "requireSpacesInConditionalExpression": { 164 | "afterTest": true, 165 | "beforeConsequent": true, 166 | "afterConsequent": true, 167 | "beforeAlternate": true 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "bitwise": true, 4 | "browser": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "esnext": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "smarttabs": true, 17 | "strict": false, 18 | "sub": true, 19 | "trailing": true, 20 | "undef": true, 21 | "unused": true, 22 | "jquery": true, 23 | "globalstrict": true, 24 | "laxcomma": true, 25 | "predef": { 26 | "__dirname": true, 27 | "include": true, 28 | "module": true, 29 | "describe":true, 30 | "before":true, 31 | "after":true, 32 | "it":true 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 6 4 | - 8 5 | - 10 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # newrelic-winston [![Build Status](https://secure.travis-ci.org/namshi/newrelic-winston.png)](http://travis-ci.org/namshi/newrelic-winston) 2 | 3 | A [newrelic][0] transport for [winston][1] including the [newrelic][2] Library 4 | 5 | ## Installation 6 | 7 | Tested on node-6.x, requires npm. 8 | 9 | ``` sh 10 | $ npm install winston --save 11 | $ npm install newrelic-winston --save 12 | ``` 13 | 14 | ## Usage 15 | ```javascript 16 | const winston = require('winston'); 17 | const NewrelicWinston = require('newrelic-winston'); 18 | winston.add(new NewrelicWinston(options)); 19 | 20 | ``` 21 | 22 | or 23 | 24 | ```javascript 25 | const { createLogger } = require('winston'); 26 | const NewrelicWinston = require('newrelic-winston'); 27 | const logger = createLogger({ 28 | transports: [ 29 | new NewrelicWinston(options), 30 | ], 31 | }); 32 | ``` 33 | ## Options 34 | * __env__: the current evironment. Defatuls to `process.env.NODE_ENV` 35 | 36 | If `env` is either 'dev' or 'test' the lib will _not_ load the included newrelic module saving devs from anoying errors ;) 37 | 38 | ## Config 39 | Please refer to the [newrelic lib's readme](https://github.com/newrelic/node-newrelic#configuring-the-module) for specific module's configs. 40 | 41 | ## Log Levels 42 | This trasport is meant to report errors to newrelic, so the only level available in order to log something is **error** 43 | 44 | **All other possible winston's levels, or custom levels, will noop** 45 | 46 | [0]: http://newrelic.com/ 47 | [1]: https://github.com/flatiron/winston 48 | [2]: https://github.com/newrelic/node-newrelic 49 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const winston = require('winston'); 4 | const TransportStream = require('winston-transport'); 5 | const { LEVEL, MESSAGE } = require('triple-beam'); 6 | 7 | /** 8 | * Transport for reporting errors to newrelic. 9 | * @type {Newrelic} 10 | * @extends {TransportStream} 11 | */ 12 | module.exports = class Newrelic extends TransportStream { 13 | /** 14 | * Constructor function for the Console transport object responsible for 15 | * persisting log messages and metadata to a terminal or TTY. 16 | * @param {!Object} [options={}] - Options for this instance. 17 | */ 18 | constructor(options = {}) { 19 | const env = options.env || process.env.NODE_ENV; 20 | super(options); 21 | this.newrelic = require('./newrelicHelper')(env); 22 | this.name = 'newrelic-winston'; 23 | } 24 | 25 | /** 26 | * 27 | * @param {Object} info 28 | * @param {function} callback 29 | */ 30 | log(info, callback) { 31 | setImmediate(() => this.emit('logged', info)); 32 | 33 | if (info[LEVEL] === 'error') { 34 | this.newrelic.noticeError(info[MESSAGE], typeof info.message === 'object' && info.message); 35 | } 36 | 37 | callback(); 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /newrelicHelper.js: -------------------------------------------------------------------------------- 1 | let newrelic = {}; 2 | const excludedEnvs = ['dev', 'test']; 3 | 4 | /** 5 | * If the newrelic module was included will invoke 6 | * the given method eventually applying params 7 | * 8 | * @param {String} methodName 9 | * @return {*} 10 | */ 11 | function callMethod(methodName) { 12 | if (newrelic[methodName]) { 13 | const args = [].splice.call(arguments, 1, (arguments.length - 1)); 14 | return newrelic[methodName].apply(newrelic, args); 15 | } 16 | } 17 | 18 | const nmNewRelic = { 19 | getBrowserTimingHeader: function() { 20 | return callMethod('getBrowserTimingHeader'); 21 | }, 22 | 23 | setTransactionName: function(name) { 24 | callMethod('setTransactionName', name); 25 | }, 26 | 27 | noticeError: function(error, options = {}) { 28 | options = options || {}; 29 | if (options.transactionName) { 30 | nmNewRelic.setTransactionName(options.transactionName); 31 | } 32 | 33 | callMethod('noticeError', error, options); 34 | } 35 | }; 36 | 37 | module.exports = function(env) { 38 | if (!Object.keys(newrelic).length && !excludedEnvs.includes(env)) { 39 | newrelic = require('newrelic'); 40 | } 41 | 42 | return nmNewRelic; 43 | }; 44 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "newrelic-winston", 3 | "version": "2.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@newrelic/koa": { 8 | "version": "1.0.8", 9 | "resolved": "https://registry.npmjs.org/@newrelic/koa/-/koa-1.0.8.tgz", 10 | "integrity": "sha512-kY//FlLQkGdUIKEeGJlyY3dJRU63EG77YIa48ACMGZxQbWRd3WZMikyft33f8XScTq6WpCDo9xa0viNo8zeYkg==", 11 | "requires": { 12 | "methods": "^1.1.2" 13 | } 14 | }, 15 | "@newrelic/native-metrics": { 16 | "version": "4.1.0", 17 | "resolved": "https://registry.npmjs.org/@newrelic/native-metrics/-/native-metrics-4.1.0.tgz", 18 | "integrity": "sha512-7CZlKMLuaYQW7mV9qVyo9b9HVe2xBnyn+kkETRJoZGs5P7gdfv9AAE3RPhtOBUopTfbmc8ju7njYadjui9J1XA==", 19 | "optional": true, 20 | "requires": { 21 | "nan": "^2.12.1", 22 | "semver": "^5.5.1" 23 | } 24 | }, 25 | "@newrelic/superagent": { 26 | "version": "1.0.3", 27 | "resolved": "https://registry.npmjs.org/@newrelic/superagent/-/superagent-1.0.3.tgz", 28 | "integrity": "sha512-lJbsqKa79qPLbHZsbiRaXl1jfzaXAN7zqqnLRqBY+zI/O5zcfyNngTmdi+9y+qIUq7xHYNaLsAxCXerrsoINKg==", 29 | "requires": { 30 | "methods": "^1.1.2" 31 | } 32 | }, 33 | "@tyriar/fibonacci-heap": { 34 | "version": "2.0.9", 35 | "resolved": "https://registry.npmjs.org/@tyriar/fibonacci-heap/-/fibonacci-heap-2.0.9.tgz", 36 | "integrity": "sha512-bYuSNomfn4hu2tPiDN+JZtnzCpSpbJ/PNeulmocDy3xN2X5OkJL65zo6rPZp65cPPhLF9vfT/dgE+RtFRCSxOA==" 37 | }, 38 | "agent-base": { 39 | "version": "4.3.0", 40 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", 41 | "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", 42 | "requires": { 43 | "es6-promisify": "^5.0.0" 44 | } 45 | }, 46 | "assertion-error": { 47 | "version": "1.1.0", 48 | "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", 49 | "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", 50 | "dev": true 51 | }, 52 | "async": { 53 | "version": "2.6.1", 54 | "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", 55 | "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", 56 | "requires": { 57 | "lodash": "^4.17.10" 58 | } 59 | }, 60 | "balanced-match": { 61 | "version": "1.0.0", 62 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 63 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 64 | "dev": true 65 | }, 66 | "brace-expansion": { 67 | "version": "1.1.11", 68 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 69 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 70 | "dev": true, 71 | "requires": { 72 | "balanced-match": "^1.0.0", 73 | "concat-map": "0.0.1" 74 | } 75 | }, 76 | "browser-stdout": { 77 | "version": "1.3.1", 78 | "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", 79 | "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", 80 | "dev": true 81 | }, 82 | "buffer-from": { 83 | "version": "1.1.1", 84 | "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", 85 | "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" 86 | }, 87 | "chai": { 88 | "version": "4.1.2", 89 | "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", 90 | "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", 91 | "dev": true, 92 | "requires": { 93 | "assertion-error": "^1.0.1", 94 | "check-error": "^1.0.1", 95 | "deep-eql": "^3.0.0", 96 | "get-func-name": "^2.0.0", 97 | "pathval": "^1.0.0", 98 | "type-detect": "^4.0.0" 99 | } 100 | }, 101 | "check-error": { 102 | "version": "1.0.2", 103 | "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", 104 | "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", 105 | "dev": true 106 | }, 107 | "color": { 108 | "version": "0.8.0", 109 | "resolved": "https://registry.npmjs.org/color/-/color-0.8.0.tgz", 110 | "integrity": "sha1-iQwHw/1OZJU3Y4kRz2keVFi2/KU=", 111 | "requires": { 112 | "color-convert": "^0.5.0", 113 | "color-string": "^0.3.0" 114 | } 115 | }, 116 | "color-convert": { 117 | "version": "0.5.3", 118 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz", 119 | "integrity": "sha1-vbbGnOZg+t/+CwAHzER+G59ygr0=" 120 | }, 121 | "color-name": { 122 | "version": "1.1.3", 123 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 124 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" 125 | }, 126 | "color-string": { 127 | "version": "0.3.0", 128 | "resolved": "https://registry.npmjs.org/color-string/-/color-string-0.3.0.tgz", 129 | "integrity": "sha1-J9RvtnAlxcL6JZk7+/V55HhBuZE=", 130 | "requires": { 131 | "color-name": "^1.0.0" 132 | } 133 | }, 134 | "colornames": { 135 | "version": "0.0.2", 136 | "resolved": "https://registry.npmjs.org/colornames/-/colornames-0.0.2.tgz", 137 | "integrity": "sha1-2BH9bIT1kClJmorEQ2ICk1uSvjE=" 138 | }, 139 | "colors": { 140 | "version": "1.3.0", 141 | "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.0.tgz", 142 | "integrity": "sha512-EDpX3a7wHMWFA7PUHWPHNWqOxIIRSJetuwl0AS5Oi/5FMV8kWm69RTlgm00GKjBO1xFHMtBbL49yRtMMdticBw==" 143 | }, 144 | "colorspace": { 145 | "version": "1.0.1", 146 | "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.0.1.tgz", 147 | "integrity": "sha1-yZx5btMRKLmHalLh7l7gOkpxl0k=", 148 | "requires": { 149 | "color": "0.8.x", 150 | "text-hex": "0.0.x" 151 | } 152 | }, 153 | "commander": { 154 | "version": "2.15.1", 155 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", 156 | "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", 157 | "dev": true 158 | }, 159 | "concat-map": { 160 | "version": "0.0.1", 161 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 162 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 163 | "dev": true 164 | }, 165 | "concat-stream": { 166 | "version": "2.0.0", 167 | "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", 168 | "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", 169 | "requires": { 170 | "buffer-from": "^1.0.0", 171 | "inherits": "^2.0.3", 172 | "readable-stream": "^3.0.2", 173 | "typedarray": "^0.0.6" 174 | }, 175 | "dependencies": { 176 | "readable-stream": { 177 | "version": "3.4.0", 178 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", 179 | "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", 180 | "requires": { 181 | "inherits": "^2.0.3", 182 | "string_decoder": "^1.1.1", 183 | "util-deprecate": "^1.0.1" 184 | } 185 | } 186 | } 187 | }, 188 | "core-util-is": { 189 | "version": "1.0.2", 190 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 191 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 192 | }, 193 | "debug": { 194 | "version": "3.1.0", 195 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 196 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 197 | "requires": { 198 | "ms": "2.0.0" 199 | } 200 | }, 201 | "deep-eql": { 202 | "version": "3.0.1", 203 | "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", 204 | "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", 205 | "dev": true, 206 | "requires": { 207 | "type-detect": "^4.0.0" 208 | } 209 | }, 210 | "diagnostics": { 211 | "version": "1.1.0", 212 | "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.0.tgz", 213 | "integrity": "sha1-4QkJALSVI+hSe+IPCBJ1IF8q42o=", 214 | "requires": { 215 | "colorspace": "1.0.x", 216 | "enabled": "1.0.x", 217 | "kuler": "0.0.x" 218 | } 219 | }, 220 | "diff": { 221 | "version": "3.5.0", 222 | "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", 223 | "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", 224 | "dev": true 225 | }, 226 | "enabled": { 227 | "version": "1.0.2", 228 | "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", 229 | "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", 230 | "requires": { 231 | "env-variable": "0.0.x" 232 | } 233 | }, 234 | "env-variable": { 235 | "version": "0.0.4", 236 | "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.4.tgz", 237 | "integrity": "sha512-+jpGxSWG4vr6gVxUHOc4p+ilPnql7NzZxOZBxNldsKGjCF+97df3CbuX7XMaDa5oAVkKQj4rKp38rYdC4VcpDg==" 238 | }, 239 | "es6-promise": { 240 | "version": "4.2.8", 241 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", 242 | "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" 243 | }, 244 | "es6-promisify": { 245 | "version": "5.0.0", 246 | "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", 247 | "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", 248 | "requires": { 249 | "es6-promise": "^4.0.3" 250 | } 251 | }, 252 | "escape-string-regexp": { 253 | "version": "1.0.5", 254 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 255 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 256 | "dev": true 257 | }, 258 | "fast-safe-stringify": { 259 | "version": "2.0.4", 260 | "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.4.tgz", 261 | "integrity": "sha512-mNlGUdKOeGNleyrmgbKYtbnCr9KZkZXU7eM89JRo8vY10f7Ul1Fbj07hUBW3N4fC0xM+fmfFfa2zM7mIizhpNQ==" 262 | }, 263 | "fecha": { 264 | "version": "2.3.3", 265 | "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", 266 | "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" 267 | }, 268 | "fill-keys": { 269 | "version": "1.0.2", 270 | "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz", 271 | "integrity": "sha1-mo+jb06K1jTjv2tPPIiCVRRS6yA=", 272 | "dev": true, 273 | "requires": { 274 | "is-object": "~1.0.1", 275 | "merge-descriptors": "~1.0.0" 276 | } 277 | }, 278 | "fs.realpath": { 279 | "version": "1.0.0", 280 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 281 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 282 | "dev": true 283 | }, 284 | "get-func-name": { 285 | "version": "2.0.0", 286 | "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", 287 | "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", 288 | "dev": true 289 | }, 290 | "glob": { 291 | "version": "7.1.2", 292 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 293 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 294 | "dev": true, 295 | "requires": { 296 | "fs.realpath": "^1.0.0", 297 | "inflight": "^1.0.4", 298 | "inherits": "2", 299 | "minimatch": "^3.0.4", 300 | "once": "^1.3.0", 301 | "path-is-absolute": "^1.0.0" 302 | } 303 | }, 304 | "growl": { 305 | "version": "1.10.5", 306 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", 307 | "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", 308 | "dev": true 309 | }, 310 | "has-flag": { 311 | "version": "3.0.0", 312 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 313 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 314 | "dev": true 315 | }, 316 | "he": { 317 | "version": "1.1.1", 318 | "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", 319 | "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", 320 | "dev": true 321 | }, 322 | "https-proxy-agent": { 323 | "version": "2.2.2", 324 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", 325 | "integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", 326 | "requires": { 327 | "agent-base": "^4.3.0", 328 | "debug": "^3.1.0" 329 | } 330 | }, 331 | "inflight": { 332 | "version": "1.0.6", 333 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 334 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 335 | "dev": true, 336 | "requires": { 337 | "once": "^1.3.0", 338 | "wrappy": "1" 339 | } 340 | }, 341 | "inherits": { 342 | "version": "2.0.3", 343 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 344 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 345 | }, 346 | "is-object": { 347 | "version": "1.0.1", 348 | "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", 349 | "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=", 350 | "dev": true 351 | }, 352 | "is-stream": { 353 | "version": "1.1.0", 354 | "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", 355 | "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" 356 | }, 357 | "isarray": { 358 | "version": "1.0.0", 359 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 360 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 361 | }, 362 | "json-stringify-safe": { 363 | "version": "5.0.1", 364 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 365 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" 366 | }, 367 | "kuler": { 368 | "version": "0.0.0", 369 | "resolved": "https://registry.npmjs.org/kuler/-/kuler-0.0.0.tgz", 370 | "integrity": "sha1-tmu0a5NOVQ9Z2BiEjgq7pPf1VTw=", 371 | "requires": { 372 | "colornames": "0.0.2" 373 | } 374 | }, 375 | "lodash": { 376 | "version": "4.17.10", 377 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", 378 | "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" 379 | }, 380 | "logform": { 381 | "version": "1.9.1", 382 | "resolved": "https://registry.npmjs.org/logform/-/logform-1.9.1.tgz", 383 | "integrity": "sha512-ZHrZE8VSf7K3xKxJiQ1aoTBp2yK+cEbFcgarsjzI3nt3nE/3O0heNSppoOQMUJVMZo/xiVwCxiXIabaZApsKNQ==", 384 | "requires": { 385 | "colors": "^1.2.1", 386 | "fast-safe-stringify": "^2.0.4", 387 | "fecha": "^2.3.3", 388 | "ms": "^2.1.1", 389 | "triple-beam": "^1.2.0" 390 | }, 391 | "dependencies": { 392 | "ms": { 393 | "version": "2.1.1", 394 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", 395 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" 396 | } 397 | } 398 | }, 399 | "merge-descriptors": { 400 | "version": "1.0.1", 401 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 402 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", 403 | "dev": true 404 | }, 405 | "methods": { 406 | "version": "1.1.2", 407 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 408 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 409 | }, 410 | "minimatch": { 411 | "version": "3.0.4", 412 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 413 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 414 | "dev": true, 415 | "requires": { 416 | "brace-expansion": "^1.1.7" 417 | } 418 | }, 419 | "minimist": { 420 | "version": "0.0.8", 421 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 422 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 423 | "dev": true 424 | }, 425 | "mkdirp": { 426 | "version": "0.5.1", 427 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 428 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 429 | "dev": true, 430 | "requires": { 431 | "minimist": "0.0.8" 432 | } 433 | }, 434 | "mocha": { 435 | "version": "5.2.0", 436 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", 437 | "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", 438 | "dev": true, 439 | "requires": { 440 | "browser-stdout": "1.3.1", 441 | "commander": "2.15.1", 442 | "debug": "3.1.0", 443 | "diff": "3.5.0", 444 | "escape-string-regexp": "1.0.5", 445 | "glob": "7.1.2", 446 | "growl": "1.10.5", 447 | "he": "1.1.1", 448 | "minimatch": "3.0.4", 449 | "mkdirp": "0.5.1", 450 | "supports-color": "5.4.0" 451 | } 452 | }, 453 | "module-not-found-error": { 454 | "version": "1.0.1", 455 | "resolved": "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz", 456 | "integrity": "sha1-z4tP9PKWQGdNbN0CsOO8UjwrvcA=", 457 | "dev": true 458 | }, 459 | "ms": { 460 | "version": "2.0.0", 461 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 462 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 463 | }, 464 | "nan": { 465 | "version": "2.14.0", 466 | "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", 467 | "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", 468 | "optional": true 469 | }, 470 | "newrelic": { 471 | "version": "5.11.0", 472 | "resolved": "https://registry.npmjs.org/newrelic/-/newrelic-5.11.0.tgz", 473 | "integrity": "sha512-KGWYdQkCIovYW8rtKE1aVu7Sl44xEGHtqXsSuInVWJJyfbI9KN0ZjnZUzdUA7SHlMM6XrW+TPY0bphSjUV2kWw==", 474 | "requires": { 475 | "@newrelic/koa": "^1.0.8", 476 | "@newrelic/native-metrics": "^4.0.0", 477 | "@newrelic/superagent": "^1.0.2", 478 | "@tyriar/fibonacci-heap": "^2.0.7", 479 | "async": "^2.1.4", 480 | "concat-stream": "^2.0.0", 481 | "https-proxy-agent": "^2.2.1", 482 | "json-stringify-safe": "^5.0.0", 483 | "readable-stream": "^3.1.1", 484 | "semver": "^5.3.0" 485 | }, 486 | "dependencies": { 487 | "readable-stream": { 488 | "version": "3.4.0", 489 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", 490 | "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", 491 | "requires": { 492 | "inherits": "^2.0.3", 493 | "string_decoder": "^1.1.1", 494 | "util-deprecate": "^1.0.1" 495 | } 496 | } 497 | } 498 | }, 499 | "once": { 500 | "version": "1.4.0", 501 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 502 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 503 | "dev": true, 504 | "requires": { 505 | "wrappy": "1" 506 | } 507 | }, 508 | "one-time": { 509 | "version": "0.0.4", 510 | "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", 511 | "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=" 512 | }, 513 | "path-is-absolute": { 514 | "version": "1.0.1", 515 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 516 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 517 | "dev": true 518 | }, 519 | "path-parse": { 520 | "version": "1.0.5", 521 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", 522 | "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", 523 | "dev": true 524 | }, 525 | "pathval": { 526 | "version": "1.1.0", 527 | "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", 528 | "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", 529 | "dev": true 530 | }, 531 | "process-nextick-args": { 532 | "version": "2.0.0", 533 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", 534 | "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" 535 | }, 536 | "proxyquire": { 537 | "version": "2.0.1", 538 | "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.0.1.tgz", 539 | "integrity": "sha512-fQr3VQrbdzHrdaDn3XuisVoJlJNDJizHAvUXw9IuXRR8BpV2x0N7LsCxrpJkeKfPbNjiNU/V5vc008cI0TmzzQ==", 540 | "dev": true, 541 | "requires": { 542 | "fill-keys": "^1.0.2", 543 | "module-not-found-error": "^1.0.0", 544 | "resolve": "~1.5.0" 545 | } 546 | }, 547 | "readable-stream": { 548 | "version": "2.3.6", 549 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", 550 | "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", 551 | "requires": { 552 | "core-util-is": "~1.0.0", 553 | "inherits": "~2.0.3", 554 | "isarray": "~1.0.0", 555 | "process-nextick-args": "~2.0.0", 556 | "safe-buffer": "~5.1.1", 557 | "string_decoder": "~1.1.1", 558 | "util-deprecate": "~1.0.1" 559 | } 560 | }, 561 | "resolve": { 562 | "version": "1.5.0", 563 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", 564 | "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", 565 | "dev": true, 566 | "requires": { 567 | "path-parse": "^1.0.5" 568 | } 569 | }, 570 | "safe-buffer": { 571 | "version": "5.1.2", 572 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 573 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 574 | }, 575 | "semver": { 576 | "version": "5.7.0", 577 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", 578 | "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" 579 | }, 580 | "stack-trace": { 581 | "version": "0.0.10", 582 | "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", 583 | "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" 584 | }, 585 | "string_decoder": { 586 | "version": "1.1.1", 587 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", 588 | "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", 589 | "requires": { 590 | "safe-buffer": "~5.1.0" 591 | } 592 | }, 593 | "supports-color": { 594 | "version": "5.4.0", 595 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", 596 | "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", 597 | "dev": true, 598 | "requires": { 599 | "has-flag": "^3.0.0" 600 | } 601 | }, 602 | "text-hex": { 603 | "version": "0.0.0", 604 | "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-0.0.0.tgz", 605 | "integrity": "sha1-V4+8haapJjbkLdF7QdAhjM6esrM=" 606 | }, 607 | "triple-beam": { 608 | "version": "1.3.0", 609 | "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", 610 | "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" 611 | }, 612 | "type-detect": { 613 | "version": "4.0.8", 614 | "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", 615 | "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", 616 | "dev": true 617 | }, 618 | "typedarray": { 619 | "version": "0.0.6", 620 | "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", 621 | "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" 622 | }, 623 | "util-deprecate": { 624 | "version": "1.0.2", 625 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 626 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 627 | }, 628 | "winston": { 629 | "version": "3.0.0", 630 | "resolved": "https://registry.npmjs.org/winston/-/winston-3.0.0.tgz", 631 | "integrity": "sha512-7QyfOo1PM5zGL6qma6NIeQQMh71FBg/8fhkSAePqtf5YEi6t+UrPDcUuHhuuUasgso49ccvMEsmqr0GBG2qaMQ==", 632 | "requires": { 633 | "async": "^2.6.0", 634 | "diagnostics": "^1.0.1", 635 | "is-stream": "^1.1.0", 636 | "logform": "^1.9.0", 637 | "one-time": "0.0.4", 638 | "readable-stream": "^2.3.6", 639 | "stack-trace": "0.0.x", 640 | "triple-beam": "^1.3.0", 641 | "winston-transport": "^4.2.0" 642 | } 643 | }, 644 | "winston-transport": { 645 | "version": "4.2.0", 646 | "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.2.0.tgz", 647 | "integrity": "sha512-0R1bvFqxSlK/ZKTH86nymOuKv/cT1PQBMuDdA7k7f0S9fM44dNH6bXnuxwXPrN8lefJgtZq08BKdyZ0DZIy/rg==", 648 | "requires": { 649 | "readable-stream": "^2.3.6", 650 | "triple-beam": "^1.2.0" 651 | } 652 | }, 653 | "wrappy": { 654 | "version": "1.0.2", 655 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 656 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 657 | "dev": true 658 | } 659 | } 660 | } 661 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "newrelic-winston", 3 | "version": "2.1.0", 4 | "description": "A newrelic transport for winston", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha -b" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/namshi/newrelic-winston.git" 12 | }, 13 | "keywords": [ 14 | "logging", 15 | "sysadmin", 16 | "tools", 17 | "winston", 18 | "newrelic" 19 | ], 20 | "author": "Luciano Colosio", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/namshi/newrelic-winston/issues" 24 | }, 25 | "homepage": "https://github.com/namshi/newrelic-winston#readme", 26 | "dependencies": { 27 | "newrelic": "^5.11.0", 28 | "winston": "^3.0.0", 29 | "winston-transport": "^4.2.0" 30 | }, 31 | "devDependencies": { 32 | "chai": "^4.1.2", 33 | "mocha": "^5.2.0", 34 | "proxyquire": "^2.0.1" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/newrelic-winston.js: -------------------------------------------------------------------------------- 1 | const stubs = { 2 | './newrelicHelper': require('./stubs/newrelicHelper') 3 | }; 4 | 5 | const { createLogger } = require('winston'); 6 | const proxyquire = require('proxyquire'); 7 | const NewrelicWinston = proxyquire.noCallThru().load('../index.js', stubs); 8 | const expect = require('chai').expect; 9 | 10 | describe('newrelic-winston', function() { 11 | describe('Creating the trasport', function() { 12 | 13 | it('Have default properties when instantiated', function() { 14 | const newrelicWinston = new(NewrelicWinston)(); 15 | 16 | expect(newrelicWinston.name).to.be.equal('newrelic-winston'); 17 | }); 18 | 19 | it('should have a log function', function() { 20 | const newrelicWinston = new(NewrelicWinston)(); 21 | expect(typeof newrelicWinston.log).to.be.equal('function'); 22 | }); 23 | 24 | it('can be registered as winston transport using the add() function', function() { 25 | const logger = createLogger({ 26 | transports: [] 27 | }); 28 | 29 | logger.add(new NewrelicWinston()); 30 | 31 | return expect(logger.transports.map(i=>i.name)).to.include('newrelic-winston'); 32 | }); 33 | 34 | it('winston.log function should not throw any errors', function() { 35 | const logger = createLogger({ 36 | transports: [new NewrelicWinston()], 37 | }); 38 | expect(() => logger.error('foo')).to.not.throw(Error); 39 | }); 40 | 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /test/newrelicHelper.js: -------------------------------------------------------------------------------- 1 | const stubs = { 2 | newrelic: require('./stubs/newrelic') 3 | }; 4 | const expect = require('chai').expect; 5 | const proxyquire = require('proxyquire'); 6 | let helper = {}; 7 | 8 | describe('Newrelic Helper', function() { 9 | 10 | describe('Dev ENV', function() { 11 | before(function() { 12 | helper = proxyquire('../newrelicHelper', stubs)('dev'); 13 | }); 14 | 15 | it('All methods whould noop and no errors should be thrown', function() { 16 | helper.getBrowserTimingHeader(); 17 | helper.setTransactionName('blah'); 18 | helper.noticeError(new Error('Ouch')); 19 | helper.noticeError(new Error('Ouch'), {transactionName: 'argh'}); 20 | }); 21 | }); 22 | 23 | describe('Test ENV', function() { 24 | before(function() { 25 | helper = proxyquire('../newrelicHelper', stubs)('test'); 26 | }); 27 | 28 | it('All methods whould noop and no errors should be thrown', function() { 29 | helper.getBrowserTimingHeader(); 30 | helper.setTransactionName('blah'); 31 | helper.noticeError(new Error('Ouch')); 32 | helper.noticeError(new Error('Ouch'), {transactionName: 'argh'}); 33 | }); 34 | }); 35 | 36 | describe('Live ENV', function() { 37 | before(function() { 38 | helper = proxyquire.noCallThru().load('../newrelicHelper', stubs)('live'); 39 | }); 40 | 41 | it('Has a getBrowserTimingHeader method returning the client javascript', function() { 42 | expect(helper.getBrowserTimingHeader()).to.be.equal('this would be the client JS script'); 43 | }); 44 | 45 | it('Should be able to set transaction name', function() { 46 | helper.setTransactionName('blah'); 47 | expect(stubs.newrelic.transactionName).to.be.equal('blah'); 48 | }); 49 | 50 | it('Should be able to notify an error', function() { 51 | expect(helper.noticeError).to.not.throw(Error); 52 | }); 53 | 54 | it('Should be able to notify an error and set a transaction name', function() { 55 | helper.noticeError(new Error('Ouch'), {transactionName: 'argh'}); 56 | expect(stubs.newrelic.transactionName).to.be.equal('argh'); 57 | }); 58 | 59 | }); 60 | 61 | }); 62 | -------------------------------------------------------------------------------- /test/stubs/newrelic.js: -------------------------------------------------------------------------------- 1 | function Newrelic() { 2 | this.transactionName = 'default'; 3 | } 4 | 5 | Newrelic.prototype.getBrowserTimingHeader = function() { 6 | return 'this would be the client JS script'; 7 | }; 8 | 9 | Newrelic.prototype.setTransactionName = function(transactionName) { 10 | this.transactionName = transactionName; 11 | }; 12 | 13 | Newrelic.prototype.noticeError = function() { 14 | }; 15 | 16 | module.exports = (function() { 17 | console.log('creating new nerelic stub instance'); 18 | return new Newrelic(); 19 | }()); 20 | -------------------------------------------------------------------------------- /test/stubs/newrelicHelper.js: -------------------------------------------------------------------------------- 1 | module.exports = function() { 2 | return { 3 | noticeError: function() {} 4 | }; 5 | }; 6 | --------------------------------------------------------------------------------