@contrast/agent 4.32.11 → 4.32.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/config/util.js +2 -1
- package/node_modules/file-stream-rotator/FileStreamRotator.js +200 -41
- package/node_modules/file-stream-rotator/LICENSE.txt +17 -0
- package/node_modules/file-stream-rotator/README.md +16 -1
- package/node_modules/file-stream-rotator/package.json +5 -5
- package/node_modules/file-stream-rotator/tests/every-minute-test.js +32 -15
- package/node_modules/file-stream-rotator/tests/every-second-test.js +16 -7
- package/node_modules/file-stream-rotator/tests/large-test.js +33 -0
- package/node_modules/file-stream-rotator/tests/rotate-on-size-without-date.js +103 -0
- package/node_modules/object-hash/dist/object_hash.js +1 -2
- package/node_modules/object-hash/index.js +33 -21
- package/node_modules/object-hash/package.json +20 -18
- package/node_modules/object-hash/readme.markdown +20 -5
- package/node_modules/winston-daily-rotate-file/README.md +81 -12
- package/node_modules/winston-daily-rotate-file/daily-rotate-file.js +69 -30
- package/node_modules/winston-daily-rotate-file/index.d.ts +119 -72
- package/node_modules/winston-daily-rotate-file/package.json +20 -19
- package/node_modules/winston-transport/.eslintrc +1 -1
- package/node_modules/winston-transport/.nyc_output/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
- package/node_modules/winston-transport/.nyc_output/processinfo/c3d7ddb9-cc26-466b-a4f6-993ad69e86f6.json +1 -0
- package/node_modules/winston-transport/.nyc_output/processinfo/index.json +1 -1
- package/node_modules/winston-transport/CHANGELOG.md +11 -0
- package/node_modules/winston-transport/dist/index.js +2 -2
- package/node_modules/winston-transport/index.d.ts +2 -0
- package/node_modules/winston-transport/index.js +2 -2
- package/node_modules/winston-transport/node_modules/readable-stream/README.md +106 -0
- package/node_modules/winston-transport/node_modules/readable-stream/errors-browser.js +127 -0
- package/node_modules/winston-transport/node_modules/readable-stream/errors.js +116 -0
- package/node_modules/winston-transport/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_duplex.js +41 -46
- package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_passthrough.js +1 -11
- package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_readable.js +271 -263
- package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_transform.js +18 -42
- package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/_stream_writable.js +101 -147
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
- package/node_modules/winston-transport/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
- package/node_modules/winston-transport/node_modules/readable-stream/package.json +72 -0
- package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/readable-browser.js +2 -0
- package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/readable.js +5 -8
- package/node_modules/winston-transport/package.json +16 -14
- package/package.json +7 -7
- package/node_modules/colors/LICENSE +0 -25
- package/node_modules/colors/README.md +0 -221
- package/node_modules/colors/examples/normal-usage.js +0 -82
- package/node_modules/colors/examples/safe-string.js +0 -79
- package/node_modules/colors/index.d.ts +0 -136
- package/node_modules/colors/lib/colors.js +0 -211
- package/node_modules/colors/lib/custom/trap.js +0 -46
- package/node_modules/colors/lib/custom/zalgo.js +0 -110
- package/node_modules/colors/lib/extendStringPrototype.js +0 -110
- package/node_modules/colors/lib/index.js +0 -13
- package/node_modules/colors/lib/maps/america.js +0 -10
- package/node_modules/colors/lib/maps/rainbow.js +0 -12
- package/node_modules/colors/lib/maps/random.js +0 -11
- package/node_modules/colors/lib/maps/zebra.js +0 -5
- package/node_modules/colors/lib/styles.js +0 -95
- package/node_modules/colors/lib/system/has-flag.js +0 -35
- package/node_modules/colors/lib/system/supports-colors.js +0 -151
- package/node_modules/colors/package.json +0 -49
- package/node_modules/colors/safe.d.ts +0 -48
- package/node_modules/colors/safe.js +0 -10
- package/node_modules/colors/themes/generic-logging.js +0 -12
- package/node_modules/core-util-is/LICENSE +0 -19
- package/node_modules/core-util-is/README.md +0 -3
- package/node_modules/core-util-is/float.patch +0 -604
- package/node_modules/core-util-is/lib/util.js +0 -107
- package/node_modules/core-util-is/package.json +0 -36
- package/node_modules/core-util-is/test.js +0 -68
- package/node_modules/cycle/README.md +0 -49
- package/node_modules/cycle/cycle.js +0 -170
- package/node_modules/cycle/package.json +0 -16
- package/node_modules/fast-safe-stringify/.travis.yml +0 -8
- package/node_modules/fast-safe-stringify/CHANGELOG.md +0 -17
- package/node_modules/fast-safe-stringify/LICENSE +0 -23
- package/node_modules/fast-safe-stringify/benchmark.js +0 -137
- package/node_modules/fast-safe-stringify/index.d.ts +0 -8
- package/node_modules/fast-safe-stringify/index.js +0 -161
- package/node_modules/fast-safe-stringify/package.json +0 -50
- package/node_modules/fast-safe-stringify/readme.md +0 -154
- package/node_modules/fast-safe-stringify/test-stable.js +0 -311
- package/node_modules/fast-safe-stringify/test.js +0 -304
- package/node_modules/isarray/.npmignore +0 -1
- package/node_modules/isarray/.travis.yml +0 -4
- package/node_modules/isarray/Makefile +0 -6
- package/node_modules/isarray/README.md +0 -60
- package/node_modules/isarray/component.json +0 -19
- package/node_modules/isarray/index.js +0 -5
- package/node_modules/isarray/package.json +0 -49
- package/node_modules/isarray/test.js +0 -20
- package/node_modules/object-hash/.jshintrc +0 -19
- package/node_modules/object-hash/.travis.yml +0 -35
- package/node_modules/object-hash/bower.json +0 -15
- package/node_modules/object-hash/dist/object_hash.js.map +0 -1
- package/node_modules/object-hash/dist/object_hash_test.js +0 -4737
- package/node_modules/object-hash/gulpfile.js +0 -97
- package/node_modules/object-hash/karma.conf.js +0 -69
- package/node_modules/object-hash/test/blob.js +0 -41
- package/node_modules/object-hash/test/index.js +0 -290
- package/node_modules/object-hash/test/object-classes.js +0 -106
- package/node_modules/object-hash/test/old-crypto.js +0 -60
- package/node_modules/object-hash/test/replacer.js +0 -36
- package/node_modules/object-hash/test/types.js +0 -174
- package/node_modules/object-hash/test/writeToStream.js +0 -27
- package/node_modules/process-nextick-args/index.js +0 -45
- package/node_modules/process-nextick-args/license.md +0 -19
- package/node_modules/process-nextick-args/package.json +0 -29
- package/node_modules/process-nextick-args/readme.md +0 -18
- package/node_modules/readable-stream/.travis.yml +0 -34
- package/node_modules/readable-stream/README.md +0 -58
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- package/node_modules/readable-stream/duplex-browser.js +0 -1
- package/node_modules/readable-stream/duplex.js +0 -1
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
- package/node_modules/readable-stream/package.json +0 -56
- package/node_modules/readable-stream/passthrough.js +0 -1
- package/node_modules/readable-stream/transform.js +0 -1
- package/node_modules/readable-stream/writable-browser.js +0 -1
- package/node_modules/readable-stream/writable.js +0 -8
- package/node_modules/winston-compat/.gitattributes +0 -1
- package/node_modules/winston-compat/.node-version +0 -1
- package/node_modules/winston-compat/CHANGELOG.md +0 -17
- package/node_modules/winston-compat/LICENSE +0 -22
- package/node_modules/winston-compat/README.md +0 -2
- package/node_modules/winston-compat/index.js +0 -295
- package/node_modules/winston-compat/lib/transport.js +0 -135
- package/node_modules/winston-compat/node_modules/fecha/CHANGELOG.md +0 -11
- package/node_modules/winston-compat/node_modules/fecha/LICENSE +0 -22
- package/node_modules/winston-compat/node_modules/fecha/README.md +0 -259
- package/node_modules/winston-compat/node_modules/fecha/fecha.d.ts +0 -47
- package/node_modules/winston-compat/node_modules/fecha/fecha.js +0 -334
- package/node_modules/winston-compat/node_modules/fecha/fecha.min.js +0 -1
- package/node_modules/winston-compat/node_modules/fecha/package.json +0 -44
- package/node_modules/winston-compat/node_modules/logform/.babelrc +0 -3
- package/node_modules/winston-compat/node_modules/logform/.eslintrc +0 -7
- package/node_modules/winston-compat/node_modules/logform/.gitattributes +0 -1
- package/node_modules/winston-compat/node_modules/logform/.travis.yml +0 -17
- package/node_modules/winston-compat/node_modules/logform/CHANGELOG.md +0 -103
- package/node_modules/winston-compat/node_modules/logform/LICENSE +0 -21
- package/node_modules/winston-compat/node_modules/logform/README.md +0 -170
- package/node_modules/winston-compat/node_modules/logform/align.js +0 -14
- package/node_modules/winston-compat/node_modules/logform/browser.js +0 -36
- package/node_modules/winston-compat/node_modules/logform/cli.js +0 -52
- package/node_modules/winston-compat/node_modules/logform/colorize.js +0 -118
- package/node_modules/winston-compat/node_modules/logform/combine.js +0 -66
- package/node_modules/winston-compat/node_modules/logform/dist/align.js +0 -14
- package/node_modules/winston-compat/node_modules/logform/dist/browser.js +0 -37
- package/node_modules/winston-compat/node_modules/logform/dist/cli.js +0 -75
- package/node_modules/winston-compat/node_modules/logform/dist/colorize.js +0 -147
- package/node_modules/winston-compat/node_modules/logform/dist/combine.js +0 -66
- package/node_modules/winston-compat/node_modules/logform/dist/format.js +0 -69
- package/node_modules/winston-compat/node_modules/logform/dist/index.js +0 -54
- package/node_modules/winston-compat/node_modules/logform/dist/json.js +0 -27
- package/node_modules/winston-compat/node_modules/logform/dist/label.js +0 -19
- package/node_modules/winston-compat/node_modules/logform/dist/levels.js +0 -15
- package/node_modules/winston-compat/node_modules/logform/dist/logstash.js +0 -32
- package/node_modules/winston-compat/node_modules/logform/dist/metadata.js +0 -63
- package/node_modules/winston-compat/node_modules/logform/dist/ms.js +0 -18
- package/node_modules/winston-compat/node_modules/logform/dist/pad-levels.js +0 -118
- package/node_modules/winston-compat/node_modules/logform/dist/pretty-print.js +0 -20
- package/node_modules/winston-compat/node_modules/logform/dist/printf.js +0 -40
- package/node_modules/winston-compat/node_modules/logform/dist/simple.js +0 -36
- package/node_modules/winston-compat/node_modules/logform/dist/splat.js +0 -147
- package/node_modules/winston-compat/node_modules/logform/dist/timestamp.js +0 -28
- package/node_modules/winston-compat/node_modules/logform/dist/uncolorize.js +0 -31
- package/node_modules/winston-compat/node_modules/logform/examples/combine.js +0 -14
- package/node_modules/winston-compat/node_modules/logform/examples/filter.js +0 -30
- package/node_modules/winston-compat/node_modules/logform/examples/invalid.js +0 -6
- package/node_modules/winston-compat/node_modules/logform/examples/metadata.js +0 -78
- package/node_modules/winston-compat/node_modules/logform/examples/padLevels.js +0 -39
- package/node_modules/winston-compat/node_modules/logform/examples/volume.js +0 -25
- package/node_modules/winston-compat/node_modules/logform/format.js +0 -52
- package/node_modules/winston-compat/node_modules/logform/index.d.ts +0 -53
- package/node_modules/winston-compat/node_modules/logform/index.js +0 -52
- package/node_modules/winston-compat/node_modules/logform/json.js +0 -26
- package/node_modules/winston-compat/node_modules/logform/label.js +0 -19
- package/node_modules/winston-compat/node_modules/logform/levels.js +0 -12
- package/node_modules/winston-compat/node_modules/logform/logstash.js +0 -29
- package/node_modules/winston-compat/node_modules/logform/metadata.js +0 -61
- package/node_modules/winston-compat/node_modules/logform/ms.js +0 -18
- package/node_modules/winston-compat/node_modules/logform/package.json +0 -51
- package/node_modules/winston-compat/node_modules/logform/pad-levels.js +0 -83
- package/node_modules/winston-compat/node_modules/logform/pretty-print.js +0 -16
- package/node_modules/winston-compat/node_modules/logform/printf.js +0 -26
- package/node_modules/winston-compat/node_modules/logform/simple.js +0 -33
- package/node_modules/winston-compat/node_modules/logform/splat.js +0 -125
- package/node_modules/winston-compat/node_modules/logform/timestamp.js +0 -30
- package/node_modules/winston-compat/node_modules/logform/tsconfig.json +0 -22
- package/node_modules/winston-compat/node_modules/logform/uncolorize.js +0 -27
- package/node_modules/winston-compat/package.json +0 -46
- package/node_modules/winston-compat/test/clone.test.js +0 -25
- package/node_modules/winston-compat/test/helpers.js +0 -256
- package/node_modules/winston-compat/test/timestamp.test.js +0 -14
- package/node_modules/winston-compat/test/transports/transport.js +0 -205
- package/node_modules/winston-compat/test/winston-compat.test.js +0 -18
- package/node_modules/winston-daily-rotate-file/.eslintrc.js +0 -11
- package/node_modules/winston-daily-rotate-file/.node-version +0 -1
- package/node_modules/winston-daily-rotate-file/.travis.yml +0 -15
- package/node_modules/winston-daily-rotate-file/node_modules/semver/CHANGELOG.md +0 -70
- package/node_modules/winston-daily-rotate-file/node_modules/semver/LICENSE +0 -15
- package/node_modules/winston-daily-rotate-file/node_modules/semver/README.md +0 -443
- package/node_modules/winston-daily-rotate-file/node_modules/semver/bin/semver.js +0 -174
- package/node_modules/winston-daily-rotate-file/node_modules/semver/package.json +0 -32
- package/node_modules/winston-daily-rotate-file/node_modules/semver/range.bnf +0 -16
- package/node_modules/winston-daily-rotate-file/node_modules/semver/semver.js +0 -1596
- package/node_modules/winston-daily-rotate-file/test/memory-stream.js +0 -38
- package/node_modules/winston-daily-rotate-file/test/random-string.js +0 -31
- package/node_modules/winston-daily-rotate-file/test/transport-tests.js +0 -250
- package/node_modules/winston-transport/.nyc_output/1c69f3e4-4c25-457d-9df5-dfa761729528.json +0 -1
- package/node_modules/winston-transport/.nyc_output/processinfo/1c69f3e4-4c25-457d-9df5-dfa761729528.json +0 -1
- package/node_modules/winston-transport/.travis.yml +0 -17
- package/node_modules/winston-transport/tsconfig.json +0 -22
- /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/CONTRIBUTING.md +0 -0
- /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/GOVERNANCE.md +0 -0
- /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/LICENSE +0 -0
- /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/internal/streams/stream-browser.js +0 -0
- /package/node_modules/{readable-stream → winston-transport/node_modules/readable-stream}/lib/internal/streams/stream.js +0 -0
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/* eslint no-unused-vars: 0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
5
|
-
|
|
6
|
-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
7
|
-
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
var _require = require('triple-beam'),
|
|
11
|
-
configs = _require.configs,
|
|
12
|
-
LEVEL = _require.LEVEL,
|
|
13
|
-
MESSAGE = _require.MESSAGE;
|
|
14
|
-
|
|
15
|
-
var Padder = function () {
|
|
16
|
-
function Padder() {
|
|
17
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { levels: configs.npm.levels };
|
|
18
|
-
|
|
19
|
-
_classCallCheck(this, Padder);
|
|
20
|
-
|
|
21
|
-
this.paddings = Padder.paddingForLevels(opts.levels, opts.filler);
|
|
22
|
-
this.options = opts;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Returns the maximum length of keys in the specified `levels` Object.
|
|
27
|
-
* @param {Object} levels Set of all levels to calculate longest level against.
|
|
28
|
-
* @returns {Number} Maximum length of the longest level string.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
_createClass(Padder, [{
|
|
33
|
-
key: 'transform',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Prepends the padding onto the `message` based on the `LEVEL` of
|
|
38
|
-
* the `info`. This is based on the behavior of `winston@2` which also
|
|
39
|
-
* prepended the level onto the message.
|
|
40
|
-
*
|
|
41
|
-
* See: https://github.com/winstonjs/winston/blob/2.x/lib/winston/logger.js#L198-L201
|
|
42
|
-
*
|
|
43
|
-
* @param {Info} info Logform info object
|
|
44
|
-
* @param {Object} opts Options passed along to this instance.
|
|
45
|
-
* @returns {Info} Modified logform info object.
|
|
46
|
-
*/
|
|
47
|
-
value: function transform(info, opts) {
|
|
48
|
-
info.message = '' + this.paddings[info[LEVEL]] + info.message;
|
|
49
|
-
if (info[MESSAGE]) {
|
|
50
|
-
info[MESSAGE] = '' + this.paddings[info[LEVEL]] + info[MESSAGE];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return info;
|
|
54
|
-
}
|
|
55
|
-
}], [{
|
|
56
|
-
key: 'getLongestLevel',
|
|
57
|
-
value: function getLongestLevel(levels) {
|
|
58
|
-
var lvls = Object.keys(levels).map(function (level) {
|
|
59
|
-
return level.length;
|
|
60
|
-
});
|
|
61
|
-
return Math.max.apply(Math, _toConsumableArray(lvls));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Returns the padding for the specified `level` assuming that the
|
|
66
|
-
* maximum length of all levels it's associated with is `maxLength`.
|
|
67
|
-
* @param {String} level Level to calculate padding for.
|
|
68
|
-
* @param {String} filler Repeatable text to use for padding.
|
|
69
|
-
* @param {Number} maxLength Length of the longest level
|
|
70
|
-
* @returns {String} Padding string for the `level`
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
}, {
|
|
74
|
-
key: 'paddingForLevel',
|
|
75
|
-
value: function paddingForLevel(level, filler, maxLength) {
|
|
76
|
-
var targetLen = maxLength + 1 - level.length;
|
|
77
|
-
var rep = Math.floor(targetLen / filler.length);
|
|
78
|
-
var padding = '' + filler + filler.repeat(rep);
|
|
79
|
-
return padding.slice(0, targetLen);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Returns an object with the string paddings for the given `levels`
|
|
84
|
-
* using the specified `filler`.
|
|
85
|
-
* @param {Object} levels Set of all levels to calculate padding for.
|
|
86
|
-
* @param {String} filler Repeatable text to use for padding.
|
|
87
|
-
* @returns {Object} Mapping of level to desired padding.
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
}, {
|
|
91
|
-
key: 'paddingForLevels',
|
|
92
|
-
value: function paddingForLevels(levels) {
|
|
93
|
-
var filler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' ';
|
|
94
|
-
|
|
95
|
-
var maxLength = Padder.getLongestLevel(levels);
|
|
96
|
-
return Object.keys(levels).reduce(function (acc, level) {
|
|
97
|
-
acc[level] = Padder.paddingForLevel(level, filler, maxLength);
|
|
98
|
-
return acc;
|
|
99
|
-
}, {});
|
|
100
|
-
}
|
|
101
|
-
}]);
|
|
102
|
-
|
|
103
|
-
return Padder;
|
|
104
|
-
}();
|
|
105
|
-
|
|
106
|
-
/*
|
|
107
|
-
* function padLevels (info)
|
|
108
|
-
* Returns a new instance of the padLevels Format which pads
|
|
109
|
-
* levels to be the same length. This was previously exposed as
|
|
110
|
-
* { padLevels: true } to transports in `winston < 3.0.0`.
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
module.exports = function (opts) {
|
|
115
|
-
return new Padder(opts);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
module.exports.Padder = module.exports.Format = Padder;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var inspect = require('util').inspect;
|
|
4
|
-
var format = require('./format');
|
|
5
|
-
|
|
6
|
-
var _require = require('triple-beam'),
|
|
7
|
-
MESSAGE = _require.MESSAGE;
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* function prettyPrint (info)
|
|
11
|
-
* Returns a new instance of the prettyPrint Format that "prettyPrint"
|
|
12
|
-
* serializes `info` objects. This was previously exposed as
|
|
13
|
-
* { prettyPrint: true } to transports in `winston < 3.0.0`.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
module.exports = format(function (info, opts) {
|
|
18
|
-
info[MESSAGE] = inspect(info, false, opts.depth || null, opts.colorize);
|
|
19
|
-
return info;
|
|
20
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
-
|
|
5
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
-
|
|
7
|
-
var _require = require('triple-beam'),
|
|
8
|
-
MESSAGE = _require.MESSAGE;
|
|
9
|
-
|
|
10
|
-
var Printf = function () {
|
|
11
|
-
function Printf(templateFn) {
|
|
12
|
-
_classCallCheck(this, Printf);
|
|
13
|
-
|
|
14
|
-
this.template = templateFn;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
_createClass(Printf, [{
|
|
18
|
-
key: 'transform',
|
|
19
|
-
value: function transform(info) {
|
|
20
|
-
info[MESSAGE] = this.template(info);
|
|
21
|
-
return info;
|
|
22
|
-
}
|
|
23
|
-
}]);
|
|
24
|
-
|
|
25
|
-
return Printf;
|
|
26
|
-
}();
|
|
27
|
-
|
|
28
|
-
/*
|
|
29
|
-
* function printf (templateFn)
|
|
30
|
-
* Returns a new instance of the printf Format that creates an
|
|
31
|
-
* intermediate prototype to store the template string-based formatter
|
|
32
|
-
* function.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
module.exports = function (opts) {
|
|
37
|
-
return new Printf(opts);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
module.exports.Printf = module.exports.Format = Printf;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* eslint no-undefined: 0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var format = require('./format');
|
|
5
|
-
|
|
6
|
-
var _require = require('triple-beam'),
|
|
7
|
-
MESSAGE = _require.MESSAGE;
|
|
8
|
-
|
|
9
|
-
var jsonStringify = require('fast-safe-stringify');
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
* function simple (info)
|
|
13
|
-
* Returns a new instance of the simple format TransformStream
|
|
14
|
-
* which writes a simple representation of logs.
|
|
15
|
-
*
|
|
16
|
-
* const { level, message, splat, ...rest } = info;
|
|
17
|
-
*
|
|
18
|
-
* ${level}: ${message} if rest is empty
|
|
19
|
-
* ${level}: ${message} ${JSON.stringify(rest)} otherwise
|
|
20
|
-
*/
|
|
21
|
-
module.exports = format(function (info) {
|
|
22
|
-
var stringifiedRest = jsonStringify(Object.assign({}, info, {
|
|
23
|
-
level: undefined,
|
|
24
|
-
message: undefined,
|
|
25
|
-
splat: undefined
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
var padding = info.padding && info.padding[info.level] || '';
|
|
29
|
-
if (stringifiedRest !== '{}') {
|
|
30
|
-
info[MESSAGE] = info.level + ':' + padding + ' ' + info.message + ' ' + stringifiedRest;
|
|
31
|
-
} else {
|
|
32
|
-
info[MESSAGE] = info.level + ':' + padding + ' ' + info.message;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return info;
|
|
36
|
-
});
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
-
|
|
5
|
-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
6
|
-
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
|
|
9
|
-
var util = require('util');
|
|
10
|
-
|
|
11
|
-
var _require = require('triple-beam'),
|
|
12
|
-
SPLAT = _require.SPLAT;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Captures the number of format (i.e. %s strings) in a given string.
|
|
16
|
-
* Based on `util.format`, see Node.js source:
|
|
17
|
-
* https://github.com/nodejs/node/blob/b1c8f15c5f169e021f7c46eb7b219de95fe97603/lib/util.js#L201-L230
|
|
18
|
-
* @type {RegExp}
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var formatRegExp = /%[scdjifoO%]/g;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Captures the number of escaped % signs in a format string (i.e. %s strings).
|
|
26
|
-
* @type {RegExp}
|
|
27
|
-
*/
|
|
28
|
-
var escapedPercent = /%%/g;
|
|
29
|
-
|
|
30
|
-
var Splatter = function () {
|
|
31
|
-
function Splatter(opts) {
|
|
32
|
-
_classCallCheck(this, Splatter);
|
|
33
|
-
|
|
34
|
-
this.options = opts;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Check to see if tokens <= splat.length, assign { splat, meta } into the
|
|
39
|
-
* `info` accordingly, and write to this instance.
|
|
40
|
-
*
|
|
41
|
-
* @param {Info} info Logform info message.
|
|
42
|
-
* @param {String[]} tokens Set of string interpolation tokens.
|
|
43
|
-
* @returns {Info} Modified info message
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
_createClass(Splatter, [{
|
|
49
|
-
key: '_splat',
|
|
50
|
-
value: function _splat(info, tokens) {
|
|
51
|
-
var msg = info.message;
|
|
52
|
-
var splat = info[SPLAT] || info.splat || [];
|
|
53
|
-
var percents = msg.match(escapedPercent);
|
|
54
|
-
var escapes = percents && percents.length || 0;
|
|
55
|
-
|
|
56
|
-
// The expected splat is the number of tokens minus the number of escapes
|
|
57
|
-
// e.g.
|
|
58
|
-
// - { expectedSplat: 3 } '%d %s %j'
|
|
59
|
-
// - { expectedSplat: 5 } '[%s] %d%% %d%% %s %j'
|
|
60
|
-
//
|
|
61
|
-
// Any "meta" will be arugments in addition to the expected splat size
|
|
62
|
-
// regardless of type. e.g.
|
|
63
|
-
//
|
|
64
|
-
// logger.log('info', '%d%% %s %j', 100, 'wow', { such: 'js' }, { thisIsMeta: true });
|
|
65
|
-
// would result in splat of four (4), but only three (3) are expected. Therefore:
|
|
66
|
-
//
|
|
67
|
-
// extraSplat = 3 - 4 = -1
|
|
68
|
-
// metas = [100, 'wow', { such: 'js' }, { thisIsMeta: true }].splice(-1, -1 * -1);
|
|
69
|
-
// splat = [100, 'wow', { such: 'js' }]
|
|
70
|
-
var expectedSplat = tokens.length - escapes;
|
|
71
|
-
var extraSplat = expectedSplat - splat.length;
|
|
72
|
-
var metas = extraSplat < 0 ? splat.splice(extraSplat, -1 * extraSplat) : [];
|
|
73
|
-
|
|
74
|
-
// Now that { splat } has been separated from any potential { meta }. we
|
|
75
|
-
// can assign this to the `info` object and write it to our format stream.
|
|
76
|
-
if (metas.length === 1) {
|
|
77
|
-
info.meta = metas[0];
|
|
78
|
-
} else if (metas.length) {
|
|
79
|
-
info.meta = metas;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
info.message = util.format.apply(util, [msg].concat(_toConsumableArray(splat)));
|
|
83
|
-
return info;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Transforms the `info` message by using `util.format` to complete
|
|
88
|
-
* any `info.message` provided it has string interpolation tokens.
|
|
89
|
-
* If no tokens exist then `info` is immutable.
|
|
90
|
-
*
|
|
91
|
-
* @param {Info} info Logform info message.
|
|
92
|
-
* @param {Object} opts Options for this instance.
|
|
93
|
-
* @returns {Info} Modified info message
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
}, {
|
|
97
|
-
key: 'transform',
|
|
98
|
-
value: function transform(info) {
|
|
99
|
-
var msg = info.message;
|
|
100
|
-
var splat = info[SPLAT] || info.splat;
|
|
101
|
-
|
|
102
|
-
// No need to process anything if splat is undefined
|
|
103
|
-
if (!splat || !splat.length) {
|
|
104
|
-
return info;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Extract tokens, if none available default to empty array to
|
|
108
|
-
// ensure consistancy in expected results
|
|
109
|
-
var tokens = msg && msg.match && msg.match(formatRegExp);
|
|
110
|
-
|
|
111
|
-
// This condition will take care of inputs with info[SPLAT]
|
|
112
|
-
// but no tokens present
|
|
113
|
-
if (!tokens && (splat || splat.length)) {
|
|
114
|
-
var metas = splat.length > 1 ? splat.splice(0) : splat;
|
|
115
|
-
|
|
116
|
-
// Now that { splat } has been separated from any potential { meta }. we
|
|
117
|
-
// can assign this to the `info` object and write it to our format stream.
|
|
118
|
-
if (metas.length === 1) {
|
|
119
|
-
info.meta = metas[0];
|
|
120
|
-
} else if (metas.length) {
|
|
121
|
-
info.meta = metas;
|
|
122
|
-
}
|
|
123
|
-
return info;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (tokens) {
|
|
127
|
-
return this._splat(info, tokens);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return info;
|
|
131
|
-
}
|
|
132
|
-
}]);
|
|
133
|
-
|
|
134
|
-
return Splatter;
|
|
135
|
-
}();
|
|
136
|
-
|
|
137
|
-
/*
|
|
138
|
-
* function splat (info)
|
|
139
|
-
* Returns a new instance of the splat format TransformStream
|
|
140
|
-
* which performs string interpolation from `info` objects. This was
|
|
141
|
-
* previously exposed implicitly in `winston < 3.0.0`.
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
module.exports = function (opts) {
|
|
146
|
-
return new Splatter(opts);
|
|
147
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var fecha = require('fecha');
|
|
4
|
-
var format = require('./format');
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* function timestamp (info)
|
|
8
|
-
* Returns a new instance of the timestamp Format which adds a timestamp
|
|
9
|
-
* to the info. It was previously available in winston < 3.0.0 as:
|
|
10
|
-
*
|
|
11
|
-
* - { timestamp: true } // `new Date.toISOString()`
|
|
12
|
-
* - { timestamp: function:String } // Value returned by `timestamp()`
|
|
13
|
-
*/
|
|
14
|
-
module.exports = format(function (info, opts) {
|
|
15
|
-
if (opts.format) {
|
|
16
|
-
info.timestamp = typeof opts.format === 'function' ? opts.format() : fecha.format(new Date(), opts.format);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (!info.timestamp) {
|
|
20
|
-
info.timestamp = new Date().toISOString();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (opts.alias) {
|
|
24
|
-
info[opts.alias] = info.timestamp;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return info;
|
|
28
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var colors = require('colors/safe');
|
|
4
|
-
var format = require('./format');
|
|
5
|
-
|
|
6
|
-
var _require = require('triple-beam'),
|
|
7
|
-
MESSAGE = _require.MESSAGE;
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
* function uncolorize (info)
|
|
11
|
-
* Returns a new instance of the uncolorize Format that strips colors
|
|
12
|
-
* from `info` objects. This was previously exposed as { stripColors: true }
|
|
13
|
-
* to transports in `winston < 3.0.0`.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
module.exports = format(function (info, opts) {
|
|
18
|
-
if (opts.level !== false) {
|
|
19
|
-
info.level = colors.strip(info.level);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (opts.message !== false) {
|
|
23
|
-
info.message = colors.strip(info.message);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (opts.raw !== false && info[MESSAGE]) {
|
|
27
|
-
info[MESSAGE] = colors.strip(info[MESSAGE]);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return info;
|
|
31
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const { format } = require('../');
|
|
2
|
-
const { combine, timestamp, label } = format;
|
|
3
|
-
|
|
4
|
-
const labelTimestamp = combine(
|
|
5
|
-
label({ label: 'right meow!' }),
|
|
6
|
-
timestamp()
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
const info = labelTimestamp.transform({
|
|
10
|
-
level: 'info',
|
|
11
|
-
message: 'What time is the testing at?'
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
console.dir(info);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* eslint no-unused-vars: 0 */
|
|
2
|
-
|
|
3
|
-
const { format } = require('../');
|
|
4
|
-
const { combine, timestamp, label } = format;
|
|
5
|
-
|
|
6
|
-
const ignorePrivate = format((info, opts) => {
|
|
7
|
-
if (info.private) { return false; }
|
|
8
|
-
return info;
|
|
9
|
-
})();
|
|
10
|
-
|
|
11
|
-
console.dir(ignorePrivate.transform({
|
|
12
|
-
level: 'error',
|
|
13
|
-
message: 'Public error to share'
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
console.dir(ignorePrivate.transform({
|
|
17
|
-
level: 'error',
|
|
18
|
-
private: true,
|
|
19
|
-
message: 'This is super secret - hide it.'
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
const willNeverThrow = format.combine(
|
|
23
|
-
format(info => { return false; })(), // Ignores everything
|
|
24
|
-
format(info => { throw new Error('Never reached'); })()
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
console.dir(willNeverThrow.transform({
|
|
28
|
-
level: 'info',
|
|
29
|
-
message: 'wow such testing'
|
|
30
|
-
}));
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
const { format } = require('../');
|
|
2
|
-
const { combine, json, metadata, timestamp } = format;
|
|
3
|
-
|
|
4
|
-
// Default Functionality (no options passed)
|
|
5
|
-
const defaultFormatter = combine(
|
|
6
|
-
timestamp(),
|
|
7
|
-
metadata(),
|
|
8
|
-
json()
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
const defaultMessage = defaultFormatter.transform({
|
|
12
|
-
level: 'info',
|
|
13
|
-
message: 'This should be a message.',
|
|
14
|
-
application: 'Microsoft Office',
|
|
15
|
-
store: 'Big Box Store',
|
|
16
|
-
purchaseAmount: '9.99'
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
console.dir(defaultMessage);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// Fill all keys into metadata except those provided
|
|
23
|
-
const formattedLogger = combine(
|
|
24
|
-
timestamp(),
|
|
25
|
-
metadata({ fillExcept: ['message', 'level', 'timestamp'] }),
|
|
26
|
-
json()
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const fillExceptMessage = formattedLogger.transform({
|
|
30
|
-
level: 'info',
|
|
31
|
-
message: 'This should have attached metadata',
|
|
32
|
-
category: 'movies',
|
|
33
|
-
subCategory: 'action'
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
console.dir(fillExceptMessage);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Fill only the keys provided into the object, and also give it a different key
|
|
40
|
-
const customMetadataLogger = combine(
|
|
41
|
-
timestamp(),
|
|
42
|
-
metadata({ fillWith: ['publisher', 'author', 'book'], key: 'bookInfo' }),
|
|
43
|
-
json()
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const fillWithMessage = customMetadataLogger.transform({
|
|
47
|
-
level: 'debug',
|
|
48
|
-
message: 'This message should be outside of the bookInfo object',
|
|
49
|
-
publisher: 'Lorem Press',
|
|
50
|
-
author: 'Albert Einstein',
|
|
51
|
-
book: '4D Chess for Dummies',
|
|
52
|
-
label: 'myCustomLabel'
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
console.dir(fillWithMessage);
|
|
56
|
-
|
|
57
|
-
// Demonstrates Metadata 'chaining' to combine multiple datapoints.
|
|
58
|
-
const chainedMetadata = combine(
|
|
59
|
-
timestamp(),
|
|
60
|
-
metadata({ fillWith: ['publisher', 'author', 'book'], key: 'bookInfo' }),
|
|
61
|
-
metadata({ fillWith: ['purchasePrice', 'purchaseDate', 'transactionId'], key: 'transactionInfo' }),
|
|
62
|
-
metadata({ fillExcept: ['level', 'message', 'label', 'timestamp'] }),
|
|
63
|
-
json()
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const chainedMessage = chainedMetadata.transform({
|
|
67
|
-
level: 'debug',
|
|
68
|
-
message: 'This message should be outside of the bookInfo object',
|
|
69
|
-
publisher: 'Lorem Press',
|
|
70
|
-
author: 'Albert Einstein',
|
|
71
|
-
book: '4D Chess for Dummies',
|
|
72
|
-
label: 'myCustomLabel',
|
|
73
|
-
purchasePrice: '9.99',
|
|
74
|
-
purchaseDate: '2.10.2018',
|
|
75
|
-
transactionId: '123ABC'
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
console.dir(chainedMessage);
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const { format } = require('../');
|
|
2
|
-
const { combine, padLevels, simple } = format;
|
|
3
|
-
|
|
4
|
-
const { MESSAGE } = require('triple-beam');
|
|
5
|
-
|
|
6
|
-
const paddedFormat = combine(
|
|
7
|
-
padLevels({
|
|
8
|
-
// Uncomment for a custom filler for the padding, defaults to ' '.
|
|
9
|
-
// filler: 'foo',
|
|
10
|
-
// Levels has to be defined, same as `winston.createLoggers({ levels })`.
|
|
11
|
-
levels: {
|
|
12
|
-
error: 0,
|
|
13
|
-
warn: 1,
|
|
14
|
-
info: 2,
|
|
15
|
-
http: 3,
|
|
16
|
-
verbose: 4,
|
|
17
|
-
debug: 5,
|
|
18
|
-
silly: 6
|
|
19
|
-
}
|
|
20
|
-
}),
|
|
21
|
-
simple()
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const info = paddedFormat.transform({
|
|
25
|
-
level: 'info',
|
|
26
|
-
message: 'This is an info level message.'
|
|
27
|
-
});
|
|
28
|
-
const error = paddedFormat.transform({
|
|
29
|
-
level: 'error',
|
|
30
|
-
message: 'This is an error level message.'
|
|
31
|
-
});
|
|
32
|
-
const verbose = paddedFormat.transform({
|
|
33
|
-
level: 'verbose',
|
|
34
|
-
message: 'This is a verbose level message.'
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
console.dir(info[MESSAGE]);
|
|
38
|
-
console.dir(error[MESSAGE]);
|
|
39
|
-
console.dir(verbose[MESSAGE]);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const { format } = require('../');
|
|
2
|
-
|
|
3
|
-
const volume = format((info, opts) => {
|
|
4
|
-
if (opts.yell) {
|
|
5
|
-
info.message = info.message.toUpperCase();
|
|
6
|
-
} else if (opts.whisper) {
|
|
7
|
-
info.message = info.message.toLowerCase();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return info;
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
// `volume` is now a function that returns instances of the format.
|
|
14
|
-
const scream = volume({ yell: true });
|
|
15
|
-
console.dir(scream.transform({
|
|
16
|
-
level: 'info',
|
|
17
|
-
message: `sorry for making you YELL in your head!`
|
|
18
|
-
}, scream.options));
|
|
19
|
-
|
|
20
|
-
// `volume` can be used multiple times to create different formats.
|
|
21
|
-
const whisper = volume({ whisper: true });
|
|
22
|
-
console.dir(whisper.transform({
|
|
23
|
-
level: 'info',
|
|
24
|
-
message: `WHY ARE THEY MAKING US YELL SO MUCH!`
|
|
25
|
-
}, whisper.options));
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Displays a helpful message and the source of
|
|
5
|
-
* the format when it is invalid.
|
|
6
|
-
*/
|
|
7
|
-
class InvalidFormatError extends Error {
|
|
8
|
-
constructor(formatFn) {
|
|
9
|
-
super(`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
10
|
-
Found: ${formatFn.toString().split('\n')[0]}\n`);
|
|
11
|
-
|
|
12
|
-
Error.captureStackTrace(this, InvalidFormatError);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/*
|
|
17
|
-
* function format (formatFn)
|
|
18
|
-
* Returns a create function for the `formatFn`.
|
|
19
|
-
*/
|
|
20
|
-
module.exports = formatFn => {
|
|
21
|
-
if (formatFn.length > 2) {
|
|
22
|
-
throw new InvalidFormatError(formatFn);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
* function Format (options)
|
|
27
|
-
* Base prototype which calls a `_format`
|
|
28
|
-
* function and pushes the result.
|
|
29
|
-
*/
|
|
30
|
-
function Format(options = {}) {
|
|
31
|
-
this.options = options;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Format.prototype.transform = formatFn;
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
// Create a function which returns new instances of
|
|
38
|
-
// FormatWrap for simple syntax like:
|
|
39
|
-
//
|
|
40
|
-
// require('winston').formats.json();
|
|
41
|
-
//
|
|
42
|
-
function createFormatWrap(opts) {
|
|
43
|
-
return new Format(opts);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
// Expose the FormatWrap through the create function
|
|
48
|
-
// for testability.
|
|
49
|
-
//
|
|
50
|
-
createFormatWrap.Format = Format;
|
|
51
|
-
return createFormatWrap;
|
|
52
|
-
};
|