standard-log-color 5.0.0 → 6.0.0
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/cjs/ansi/wrapAnsi.spec.js +6 -2
- package/cjs/ansi/wrapAnsi.spec.js.map +1 -1
- package/cjs/createColorLogReporter.spec.js +2 -139
- package/cjs/createColorLogReporter.spec.js.map +1 -1
- package/cjs/package.json +1 -3
- package/esm/ansi/wrapAnsi.spec.js +7 -3
- package/esm/ansi/wrapAnsi.spec.js.map +1 -1
- package/esm/createColorLogReporter.spec.js +3 -116
- package/esm/createColorLogReporter.spec.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var wrapAnsi_js_1 = require("./wrapAnsi.js");
|
|
4
3
|
var constants_js_1 = require("./constants.js");
|
|
4
|
+
var wrapAnsi_js_1 = require("./wrapAnsi.js");
|
|
5
5
|
test('no background will not pad', function () {
|
|
6
|
-
var actual = (0, wrapAnsi_js_1.
|
|
6
|
+
var actual = (0, wrapAnsi_js_1.wrapAnsiId)('abc', [constants_js_1.ANSI_RED + constants_js_1.ANSI_FOREGROUND]);
|
|
7
7
|
expect(actual).toBe("\u001B[".concat(constants_js_1.ANSI_RED + constants_js_1.ANSI_FOREGROUND, "m").concat('abc', "\u001B[0m"));
|
|
8
8
|
});
|
|
9
|
+
it('will pad with background', function () {
|
|
10
|
+
var actual = (0, wrapAnsi_js_1.wrapAnsiId)('abc', [constants_js_1.ANSI_RED + constants_js_1.ANSI_BACKGROUND]);
|
|
11
|
+
expect(actual).toBe("\u001B[".concat(constants_js_1.ANSI_RED + constants_js_1.ANSI_BACKGROUND, "m").concat(' abc ', "\u001B[0m"));
|
|
12
|
+
});
|
|
9
13
|
//# sourceMappingURL=wrapAnsi.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapAnsi.spec.js","sourceRoot":"","sources":["../../ts/ansi/wrapAnsi.spec.ts"],"names":[],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"file":"wrapAnsi.spec.js","sourceRoot":"","sources":["../../ts/ansi/wrapAnsi.spec.ts"],"names":[],"mappings":";;AAAA,+CAA2E;AAC3E,6CAA0C;AAE1C,IAAI,CAAC,4BAA4B,EAAE;IACjC,IAAM,MAAM,GAAG,IAAA,wBAAU,EAAC,KAAK,EAAE,CAAC,uBAAQ,GAAG,8BAAe,CAAC,CAAC,CAAA;IAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,iBAAU,uBAAQ,GAAG,8BAAe,cAAI,KAAK,cAAW,CAAC,CAAA;AAC/E,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,0BAA0B,EAAE;IAC7B,IAAM,MAAM,GAAG,IAAA,wBAAU,EAAC,KAAK,EAAE,CAAC,uBAAQ,GAAG,8BAAe,CAAC,CAAC,CAAA;IAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,iBAAU,uBAAQ,GAAG,8BAAe,cAAI,OAAO,cAAW,CAAC,CAAA;AACjF,CAAC,CAAC,CAAA","sourcesContent":["import { ANSI_BACKGROUND, ANSI_FOREGROUND, ANSI_RED } from './constants.js'\nimport { wrapAnsiId } from './wrapAnsi.js'\n\ntest('no background will not pad', () => {\n const actual = wrapAnsiId('abc', [ANSI_RED + ANSI_FOREGROUND])\n expect(actual).toBe(`\\u001B[${ANSI_RED + ANSI_FOREGROUND}m${'abc'}\\u001B[0m`)\n})\n\nit('will pad with background', () => {\n const actual = wrapAnsiId('abc', [ANSI_RED + ANSI_BACKGROUND])\n expect(actual).toBe(`\\u001B[${ANSI_RED + ANSI_BACKGROUND}m${' abc '}\\u001B[0m`)\n})\n"]}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var standard_log_1 = require("standard-log");
|
|
4
4
|
var index_js_1 = require("./index.js");
|
|
5
|
-
beforeAll(function () { return (0, standard_log_1.configForTest)(); });
|
|
6
5
|
describe('rendering tests', function () {
|
|
7
6
|
test('default to color rendering', function () {
|
|
8
7
|
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
@@ -17,16 +16,14 @@ describe('rendering tests', function () {
|
|
|
17
16
|
});
|
|
18
17
|
});
|
|
19
18
|
test('different timestamp settings', function () {
|
|
20
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
21
19
|
['none', 'iso', 'elapsed'].forEach(function (timestamp) {
|
|
22
|
-
reporter
|
|
20
|
+
var reporter = (0, index_js_1.createColorLogReporter)({ formatter: (0, index_js_1.createAnsiFormatter)({ timestamp: timestamp }) });
|
|
23
21
|
reporter.write({ id: timestamp, level: standard_log_1.logLevels.info, args: ['hello', 'world'], timestamp: new Date() });
|
|
24
22
|
});
|
|
25
23
|
});
|
|
26
24
|
test('different timestamp settings for css', function () {
|
|
27
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
28
25
|
['none', 'iso', 'elapsed'].forEach(function (timestamp) {
|
|
29
|
-
reporter
|
|
26
|
+
var reporter = (0, index_js_1.createColorLogReporter)({ formatter: (0, index_js_1.createCssFormatter)({ timestamp: timestamp }) });
|
|
30
27
|
reporter.write({ id: timestamp, level: standard_log_1.logLevels.info, args: ['hello', 'world'], timestamp: new Date() });
|
|
31
28
|
});
|
|
32
29
|
});
|
|
@@ -41,138 +38,4 @@ describe('id', function () {
|
|
|
41
38
|
expect(reporter.id).toBe('neo-console');
|
|
42
39
|
});
|
|
43
40
|
});
|
|
44
|
-
describe('log level', function () {
|
|
45
|
-
test('error, alert, critical and emergency logs are written to console.error', function () {
|
|
46
|
-
var id = 'log';
|
|
47
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
48
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
49
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
50
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.critical, args: ['critical'], timestamp: new Date() });
|
|
51
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.alert, args: ['alert'], timestamp: new Date() });
|
|
52
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.error, args: ['error'], timestamp: new Date() });
|
|
53
|
-
expect(fakeConsole.errors.length).toBe(4);
|
|
54
|
-
});
|
|
55
|
-
test('warn logs are written to console.warn', function () {
|
|
56
|
-
var id = 'log';
|
|
57
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
58
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
59
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.warn, args: ['warn'], timestamp: new Date() });
|
|
60
|
-
expect(fakeConsole.warns.length).toBe(1);
|
|
61
|
-
});
|
|
62
|
-
test('notice and info logs are written to console.info', function () {
|
|
63
|
-
var id = 'log';
|
|
64
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
65
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
66
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.notice, args: ['notice'], timestamp: new Date() });
|
|
67
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.info, args: ['info'], timestamp: new Date() });
|
|
68
|
-
expect(fakeConsole.infos.length).toBe(2);
|
|
69
|
-
});
|
|
70
|
-
test('debug, trace, and planck logs are written to console.debug', function () {
|
|
71
|
-
var id = 'log';
|
|
72
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
73
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
74
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.debug, args: ['debug'], timestamp: new Date() });
|
|
75
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.trace, args: ['trace'], timestamp: new Date() });
|
|
76
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.planck, args: ['planck'], timestamp: new Date() });
|
|
77
|
-
expect(fakeConsole.debugs.length).toBe(3);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe('custom logs', function () {
|
|
81
|
-
afterEach(function () { return (0, standard_log_1.clearCustomLogLevel)(); });
|
|
82
|
-
test('are written according to their log level value', function () {
|
|
83
|
-
(0, standard_log_1.addCustomLogLevel)('high', 50);
|
|
84
|
-
(0, standard_log_1.addCustomLogLevel)('important', 450);
|
|
85
|
-
(0, standard_log_1.addCustomLogLevel)('interest', 650);
|
|
86
|
-
(0, standard_log_1.addCustomLogLevel)('silly', 1000);
|
|
87
|
-
var id = 'log';
|
|
88
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
89
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
90
|
-
reporter.write({ id: id, level: 50, args: ['a'], timestamp: new Date() });
|
|
91
|
-
reporter.write({ id: id, level: 450, args: ['b'], timestamp: new Date() });
|
|
92
|
-
reporter.write({ id: id, level: 650, args: ['c'], timestamp: new Date() });
|
|
93
|
-
reporter.write({ id: id, level: 1000, args: ['d'], timestamp: new Date() });
|
|
94
|
-
expect(fakeConsole.errors.length).toBe(1);
|
|
95
|
-
expect(fakeConsole.warns.length).toBe(1);
|
|
96
|
-
expect(fakeConsole.infos.length).toBe(1);
|
|
97
|
-
expect(fakeConsole.debugs.length).toBe(1);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
var idFormatter = function (entry) { return [entry.id]; };
|
|
101
|
-
describe('formatter', function () {
|
|
102
|
-
test('use specific formatter', function () {
|
|
103
|
-
var id = 'id-only';
|
|
104
|
-
var reporter = (0, index_js_1.createColorLogReporter)({ formatter: idFormatter });
|
|
105
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
106
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
107
|
-
expect(fakeConsole.errors).toEqual([['id-only']]);
|
|
108
|
-
});
|
|
109
|
-
test('formatter can be changed afterward', function () {
|
|
110
|
-
var id = 'id-only';
|
|
111
|
-
var reporter = (0, index_js_1.createColorLogReporter)();
|
|
112
|
-
reporter.formatter = idFormatter;
|
|
113
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
114
|
-
reporter.write({ id: id, level: standard_log_1.logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
115
|
-
expect(fakeConsole.errors).toEqual([['id-only']]);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe('filter', function () {
|
|
119
|
-
var filter = function (entry) { return entry.id !== 'secret'; };
|
|
120
|
-
test('use specific filter', function () {
|
|
121
|
-
var reporter = (0, index_js_1.createColorLogReporter)({ formatter: idFormatter, filter: filter });
|
|
122
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
123
|
-
reporter.write({ id: 'normal', level: standard_log_1.logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
124
|
-
reporter.write({ id: 'secret', level: standard_log_1.logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
125
|
-
expect(fakeConsole.errors).toEqual([['normal']]);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
test('write log entry with multiple arguments', function () {
|
|
129
|
-
var id = 'log';
|
|
130
|
-
var reporter = (0, index_js_1.createColorLogReporter)({ formatter: standard_log_1.plainLogFormatter });
|
|
131
|
-
var fakeConsole = reporter.console = createFakeConsole();
|
|
132
|
-
var entry = { id: id, level: standard_log_1.logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() };
|
|
133
|
-
reporter.write(entry);
|
|
134
|
-
expect(fakeConsole.infos).toEqual([
|
|
135
|
-
[entry.timestamp.toISOString(), 'log', '(INFO)', 'a', 'b', 'c']
|
|
136
|
-
]);
|
|
137
|
-
});
|
|
138
|
-
function createFakeConsole() {
|
|
139
|
-
var errors = [];
|
|
140
|
-
var infos = [];
|
|
141
|
-
var warns = [];
|
|
142
|
-
var debugs = [];
|
|
143
|
-
return {
|
|
144
|
-
errors: errors,
|
|
145
|
-
infos: infos,
|
|
146
|
-
warns: warns,
|
|
147
|
-
debugs: debugs,
|
|
148
|
-
error: function () {
|
|
149
|
-
var args = [];
|
|
150
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
151
|
-
args[_i] = arguments[_i];
|
|
152
|
-
}
|
|
153
|
-
errors.push(args);
|
|
154
|
-
},
|
|
155
|
-
info: function () {
|
|
156
|
-
var args = [];
|
|
157
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
158
|
-
args[_i] = arguments[_i];
|
|
159
|
-
}
|
|
160
|
-
infos.push(args);
|
|
161
|
-
},
|
|
162
|
-
warn: function () {
|
|
163
|
-
var args = [];
|
|
164
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
165
|
-
args[_i] = arguments[_i];
|
|
166
|
-
}
|
|
167
|
-
warns.push(args);
|
|
168
|
-
},
|
|
169
|
-
debug: function () {
|
|
170
|
-
var args = [];
|
|
171
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
172
|
-
args[_i] = arguments[_i];
|
|
173
|
-
}
|
|
174
|
-
debugs.push(args);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
41
|
//# sourceMappingURL=createColorLogReporter.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createColorLogReporter.spec.js","sourceRoot":"","sources":["../ts/createColorLogReporter.spec.ts"],"names":[],"mappings":";;AAAA,6CAGqB;AACrB,uCAA4F;AAE5F,SAAS,CAAC,cAAM,OAAA,IAAA,4BAAa,GAAE,EAAf,CAAe,CAAC,CAAA;AAEhC,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,IAAI,CAAC,4BAA4B,EAAE;QACjC,IAAM,QAAQ,GAAG,IAAA,iCAAsB,GAAE,CAAC;QAC1C,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,UAAA,KAAK;YAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAG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Ac,EAAd,IAAc;gBAAd,yBAAc;;YAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAAC,CAAC;QAC3C,IAAI,EAAJ;YAAK,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAAC,CAAC;QACzC,IAAI,EAAJ;YAAK,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAAC,CAAC;QACzC,KAAK,EAAL;YAAM,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAAC,CAAC;KAC5C,CAAA;AACH,CAAC","sourcesContent":["import {\n addCustomLogLevel, clearCustomLogLevel, configForTest,\n ConsoleLogFormatter, LogFilter, logLevels, plainLogFormatter\n} from 'standard-log'\nimport { createAnsiFormatter, createColorLogReporter, createCssFormatter } from './index.js'\n\nbeforeAll(() => configForTest())\n\ndescribe('rendering tests', () => {\n test('default to color rendering', () => {\n const reporter = createColorLogReporter();\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'color', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('plain rendering', () => {\n const reporter = createColorLogReporter({ formatter: plainLogFormatter });\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'plain', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n\n test('different timestamp settings', () => {\n const reporter = createColorLogReporter();\n\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n reporter.formatter = createAnsiFormatter({ timestamp })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('different timestamp settings for css', () => {\n const reporter = createColorLogReporter();\n\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n reporter.formatter = createCssFormatter({ timestamp })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n})\n\ndescribe('id', () => {\n test('default is \"console\"', () => {\n const reporter = createColorLogReporter()\n expect(reporter.id).toBe('console')\n })\n test('can be overridden', () => {\n const reporter = createColorLogReporter({ id: 'neo-console' })\n expect(reporter.id).toBe('neo-console')\n })\n})\n\ndescribe('log level', () => {\n test('error, alert, critical and emergency logs are written to console.error', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.error, args: ['error'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(4)\n })\n\n test('warn logs are written to console.warn', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() })\n\n expect(fakeConsole.warns.length).toBe(1)\n })\n\n test('notice and info logs are written to console.info', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() })\n\n expect(fakeConsole.infos.length).toBe(2)\n })\n\n\n test('debug, trace, and planck logs are written to console.debug', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() })\n\n expect(fakeConsole.debugs.length).toBe(3)\n })\n})\n\ndescribe('custom logs', () => {\n afterEach(() => clearCustomLogLevel())\n\n test('are written according to their log level value', () => {\n addCustomLogLevel('high', 50)\n addCustomLogLevel('important', 450)\n addCustomLogLevel('interest', 650)\n addCustomLogLevel('silly', 1000)\n\n const id = 'log'\n const reporter = createColorLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: 50, args: ['a'], timestamp: new Date() })\n reporter.write({ id, level: 450, args: ['b'], timestamp: new Date() })\n reporter.write({ id, level: 650, args: ['c'], timestamp: new Date() })\n reporter.write({ id, level: 1000, args: ['d'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(1)\n expect(fakeConsole.warns.length).toBe(1)\n expect(fakeConsole.infos.length).toBe(1)\n expect(fakeConsole.debugs.length).toBe(1)\n })\n})\n\nconst idFormatter: ConsoleLogFormatter = (entry) => [entry.id]\n\ndescribe('formatter', () => {\n test('use specific formatter', () => {\n const id = 'id-only'\n const reporter = createColorLogReporter({ formatter: idFormatter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\n })\n\n test('formatter can be changed afterward', () => {\n const id = 'id-only'\n const reporter = createColorLogReporter()\n reporter.formatter = idFormatter\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\n })\n})\n\ndescribe('filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n test('use specific filter', () => {\n const reporter = createColorLogReporter({ formatter: idFormatter, filter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['normal']])\n })\n})\n\ntest('write log entry with multiple arguments', () => {\n const id = 'log'\n const reporter = createColorLogReporter({ formatter: plainLogFormatter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() }\n\n reporter.write(entry)\n\n expect(fakeConsole.infos).toEqual([\n [entry.timestamp.toISOString(), 'log', '(INFO)', 'a', 'b', 'c']\n ])\n})\n\nfunction createFakeConsole() {\n const errors: any[] = []\n const infos: any[] = []\n const warns: any[] = []\n const debugs: any[] = []\n return {\n errors,\n infos,\n warns,\n debugs,\n error(...args: any[]) { errors.push(args) },\n info(...args: any[]) { infos.push(args) },\n warn(...args: any[]) { warns.push(args) },\n debug(...args: any[]) { debugs.push(args) }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createColorLogReporter.spec.js","sourceRoot":"","sources":["../ts/createColorLogReporter.spec.ts"],"names":[],"mappings":";;AAAA,6CAA2D;AAC3D,uCAA4F;AAE5F,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,IAAI,CAAC,4BAA4B,EAAE;QACjC,IAAM,QAAQ,GAAG,IAAA,iCAAsB,GAAE,CAAC;QAC1C,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,UAAA,KAAK;YAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAG,wBAAiB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;QACpH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,iBAAiB,EAAE;QACtB,IAAM,QAAQ,GAAG,IAAA,iCAAsB,EAAC,EAAE,SAAS,EAAE,gCAAiB,EAA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E,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;QAC3G,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,IAAI,EAAE;IACb,IAAI,CAAC,sBAAsB,EAAE;QAC3B,IAAM,QAAQ,GAAG,IAAA,iCAAsB,GAAE,CAAA;QACzC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,mBAAmB,EAAE;QACxB,IAAM,QAAQ,GAAG,IAAA,iCAAsB,EAAC,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,CAAA;QAC9D,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { logLevels, plainLogFormatter } from 'standard-log'\nimport { createAnsiFormatter, createColorLogReporter, createCssFormatter } from './index.js'\n\ndescribe('rendering tests', () => {\n test('default to color rendering', () => {\n const reporter = createColorLogReporter();\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'color', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('plain rendering', () => {\n const reporter = createColorLogReporter({ formatter: plainLogFormatter });\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'plain', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n\n test('different timestamp settings', () => {\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n const reporter = createColorLogReporter({ formatter: createAnsiFormatter({ timestamp }) })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('different timestamp settings for css', () => {\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n const reporter = createColorLogReporter({ formatter: createCssFormatter({ timestamp }) })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n})\n\ndescribe('id', () => {\n test('default is \"console\"', () => {\n const reporter = createColorLogReporter()\n expect(reporter.id).toBe('console')\n })\n test('can be overridden', () => {\n const reporter = createColorLogReporter({ id: 'neo-console' })\n expect(reporter.id).toBe('neo-console')\n })\n})\n\n"]}
|
package/cjs/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ANSI_BACKGROUND, ANSI_FOREGROUND, ANSI_RED } from './constants.js';
|
|
2
|
+
import { wrapAnsiId } from './wrapAnsi.js';
|
|
3
3
|
test('no background will not pad', () => {
|
|
4
|
-
const actual =
|
|
4
|
+
const actual = wrapAnsiId('abc', [ANSI_RED + ANSI_FOREGROUND]);
|
|
5
5
|
expect(actual).toBe(`\u001B[${ANSI_RED + ANSI_FOREGROUND}m${'abc'}\u001B[0m`);
|
|
6
6
|
});
|
|
7
|
+
it('will pad with background', () => {
|
|
8
|
+
const actual = wrapAnsiId('abc', [ANSI_RED + ANSI_BACKGROUND]);
|
|
9
|
+
expect(actual).toBe(`\u001B[${ANSI_RED + ANSI_BACKGROUND}m${' abc '}\u001B[0m`);
|
|
10
|
+
});
|
|
7
11
|
//# sourceMappingURL=wrapAnsi.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapAnsi.spec.js","sourceRoot":"","sources":["../../ts/ansi/wrapAnsi.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"wrapAnsi.spec.js","sourceRoot":"","sources":["../../ts/ansi/wrapAnsi.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACtC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAA;IAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,QAAQ,GAAG,eAAe,IAAI,KAAK,WAAW,CAAC,CAAA;AAC/E,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;IAClC,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAA;IAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,QAAQ,GAAG,eAAe,IAAI,OAAO,WAAW,CAAC,CAAA;AACjF,CAAC,CAAC,CAAA","sourcesContent":["import { ANSI_BACKGROUND, ANSI_FOREGROUND, ANSI_RED } from './constants.js'\nimport { wrapAnsiId } from './wrapAnsi.js'\n\ntest('no background will not pad', () => {\n const actual = wrapAnsiId('abc', [ANSI_RED + ANSI_FOREGROUND])\n expect(actual).toBe(`\\u001B[${ANSI_RED + ANSI_FOREGROUND}m${'abc'}\\u001B[0m`)\n})\n\nit('will pad with background', () => {\n const actual = wrapAnsiId('abc', [ANSI_RED + ANSI_BACKGROUND])\n expect(actual).toBe(`\\u001B[${ANSI_RED + ANSI_BACKGROUND}m${' abc '}\\u001B[0m`)\n})\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logLevels, plainLogFormatter } from 'standard-log';
|
|
2
2
|
import { createAnsiFormatter, createColorLogReporter, createCssFormatter } from './index.js';
|
|
3
|
-
beforeAll(() => configForTest());
|
|
4
3
|
describe('rendering tests', () => {
|
|
5
4
|
test('default to color rendering', () => {
|
|
6
5
|
const reporter = createColorLogReporter();
|
|
@@ -15,16 +14,14 @@ describe('rendering tests', () => {
|
|
|
15
14
|
});
|
|
16
15
|
});
|
|
17
16
|
test('different timestamp settings', () => {
|
|
18
|
-
const reporter = createColorLogReporter();
|
|
19
17
|
['none', 'iso', 'elapsed'].forEach((timestamp) => {
|
|
20
|
-
reporter
|
|
18
|
+
const reporter = createColorLogReporter({ formatter: createAnsiFormatter({ timestamp }) });
|
|
21
19
|
reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() });
|
|
22
20
|
});
|
|
23
21
|
});
|
|
24
22
|
test('different timestamp settings for css', () => {
|
|
25
|
-
const reporter = createColorLogReporter();
|
|
26
23
|
['none', 'iso', 'elapsed'].forEach((timestamp) => {
|
|
27
|
-
reporter
|
|
24
|
+
const reporter = createColorLogReporter({ formatter: createCssFormatter({ timestamp }) });
|
|
28
25
|
reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() });
|
|
29
26
|
});
|
|
30
27
|
});
|
|
@@ -39,114 +36,4 @@ describe('id', () => {
|
|
|
39
36
|
expect(reporter.id).toBe('neo-console');
|
|
40
37
|
});
|
|
41
38
|
});
|
|
42
|
-
describe('log level', () => {
|
|
43
|
-
test('error, alert, critical and emergency logs are written to console.error', () => {
|
|
44
|
-
const id = 'log';
|
|
45
|
-
const reporter = createColorLogReporter();
|
|
46
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
47
|
-
reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
48
|
-
reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() });
|
|
49
|
-
reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() });
|
|
50
|
-
reporter.write({ id, level: logLevels.error, args: ['error'], timestamp: new Date() });
|
|
51
|
-
expect(fakeConsole.errors.length).toBe(4);
|
|
52
|
-
});
|
|
53
|
-
test('warn logs are written to console.warn', () => {
|
|
54
|
-
const id = 'log';
|
|
55
|
-
const reporter = createColorLogReporter();
|
|
56
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
57
|
-
reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() });
|
|
58
|
-
expect(fakeConsole.warns.length).toBe(1);
|
|
59
|
-
});
|
|
60
|
-
test('notice and info logs are written to console.info', () => {
|
|
61
|
-
const id = 'log';
|
|
62
|
-
const reporter = createColorLogReporter();
|
|
63
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
64
|
-
reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() });
|
|
65
|
-
reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() });
|
|
66
|
-
expect(fakeConsole.infos.length).toBe(2);
|
|
67
|
-
});
|
|
68
|
-
test('debug, trace, and planck logs are written to console.debug', () => {
|
|
69
|
-
const id = 'log';
|
|
70
|
-
const reporter = createColorLogReporter();
|
|
71
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
72
|
-
reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() });
|
|
73
|
-
reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() });
|
|
74
|
-
reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() });
|
|
75
|
-
expect(fakeConsole.debugs.length).toBe(3);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
describe('custom logs', () => {
|
|
79
|
-
afterEach(() => clearCustomLogLevel());
|
|
80
|
-
test('are written according to their log level value', () => {
|
|
81
|
-
addCustomLogLevel('high', 50);
|
|
82
|
-
addCustomLogLevel('important', 450);
|
|
83
|
-
addCustomLogLevel('interest', 650);
|
|
84
|
-
addCustomLogLevel('silly', 1000);
|
|
85
|
-
const id = 'log';
|
|
86
|
-
const reporter = createColorLogReporter();
|
|
87
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
88
|
-
reporter.write({ id, level: 50, args: ['a'], timestamp: new Date() });
|
|
89
|
-
reporter.write({ id, level: 450, args: ['b'], timestamp: new Date() });
|
|
90
|
-
reporter.write({ id, level: 650, args: ['c'], timestamp: new Date() });
|
|
91
|
-
reporter.write({ id, level: 1000, args: ['d'], timestamp: new Date() });
|
|
92
|
-
expect(fakeConsole.errors.length).toBe(1);
|
|
93
|
-
expect(fakeConsole.warns.length).toBe(1);
|
|
94
|
-
expect(fakeConsole.infos.length).toBe(1);
|
|
95
|
-
expect(fakeConsole.debugs.length).toBe(1);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
const idFormatter = (entry) => [entry.id];
|
|
99
|
-
describe('formatter', () => {
|
|
100
|
-
test('use specific formatter', () => {
|
|
101
|
-
const id = 'id-only';
|
|
102
|
-
const reporter = createColorLogReporter({ formatter: idFormatter });
|
|
103
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
104
|
-
reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
105
|
-
expect(fakeConsole.errors).toEqual([['id-only']]);
|
|
106
|
-
});
|
|
107
|
-
test('formatter can be changed afterward', () => {
|
|
108
|
-
const id = 'id-only';
|
|
109
|
-
const reporter = createColorLogReporter();
|
|
110
|
-
reporter.formatter = idFormatter;
|
|
111
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
112
|
-
reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
113
|
-
expect(fakeConsole.errors).toEqual([['id-only']]);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe('filter', () => {
|
|
117
|
-
const filter = (entry) => entry.id !== 'secret';
|
|
118
|
-
test('use specific filter', () => {
|
|
119
|
-
const reporter = createColorLogReporter({ formatter: idFormatter, filter });
|
|
120
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
121
|
-
reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
122
|
-
reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() });
|
|
123
|
-
expect(fakeConsole.errors).toEqual([['normal']]);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
test('write log entry with multiple arguments', () => {
|
|
127
|
-
const id = 'log';
|
|
128
|
-
const reporter = createColorLogReporter({ formatter: plainLogFormatter });
|
|
129
|
-
const fakeConsole = reporter.console = createFakeConsole();
|
|
130
|
-
const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() };
|
|
131
|
-
reporter.write(entry);
|
|
132
|
-
expect(fakeConsole.infos).toEqual([
|
|
133
|
-
[entry.timestamp.toISOString(), 'log', '(INFO)', 'a', 'b', 'c']
|
|
134
|
-
]);
|
|
135
|
-
});
|
|
136
|
-
function createFakeConsole() {
|
|
137
|
-
const errors = [];
|
|
138
|
-
const infos = [];
|
|
139
|
-
const warns = [];
|
|
140
|
-
const debugs = [];
|
|
141
|
-
return {
|
|
142
|
-
errors,
|
|
143
|
-
infos,
|
|
144
|
-
warns,
|
|
145
|
-
debugs,
|
|
146
|
-
error(...args) { errors.push(args); },
|
|
147
|
-
info(...args) { infos.push(args); },
|
|
148
|
-
warn(...args) { warns.push(args); },
|
|
149
|
-
debug(...args) { debugs.push(args); }
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
39
|
//# sourceMappingURL=createColorLogReporter.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createColorLogReporter.spec.js","sourceRoot":"","sources":["../ts/createColorLogReporter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAAE,mBAAmB,EAAE,aAAa,EACrB,SAAS,EAAE,iBAAiB,EAC7D,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE5F,SAAS,CAAC,GAAG,EAAE,CAAC,aAAa,EAAE,CAAC,CAAA;AAEhC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACtC,MAAM,QAAQ,GAAG,sBAA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MAAM,GAAU,EAAE,CAAA;IACxB,OAAO;QACL,MAAM;QACN,KAAK;QACL,KAAK;QACL,MAAM;QACN,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,IAAW,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;QACzC,KAAK,CAAC,GAAG,IAAW,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC,CAAC;KAC5C,CAAA;AACH,CAAC","sourcesContent":["import {\n addCustomLogLevel, clearCustomLogLevel, configForTest,\n ConsoleLogFormatter, LogFilter, logLevels, plainLogFormatter\n} from 'standard-log'\nimport { createAnsiFormatter, createColorLogReporter, createCssFormatter } from './index.js'\n\nbeforeAll(() => configForTest())\n\ndescribe('rendering tests', () => {\n test('default to color rendering', () => {\n const reporter = createColorLogReporter();\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'color', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('plain rendering', () => {\n const reporter = createColorLogReporter({ formatter: plainLogFormatter });\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'plain', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n\n test('different timestamp settings', () => {\n const reporter = createColorLogReporter();\n\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n reporter.formatter = createAnsiFormatter({ timestamp })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('different timestamp settings for css', () => {\n const reporter = createColorLogReporter();\n\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n reporter.formatter = createCssFormatter({ timestamp })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n})\n\ndescribe('id', () => {\n test('default is \"console\"', () => {\n const reporter = createColorLogReporter()\n expect(reporter.id).toBe('console')\n })\n test('can be overridden', () => {\n const reporter = createColorLogReporter({ id: 'neo-console' })\n expect(reporter.id).toBe('neo-console')\n })\n})\n\ndescribe('log level', () => {\n test('error, alert, critical and emergency logs are written to console.error', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.critical, args: ['critical'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.alert, args: ['alert'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.error, args: ['error'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(4)\n })\n\n test('warn logs are written to console.warn', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.warn, args: ['warn'], timestamp: new Date() })\n\n expect(fakeConsole.warns.length).toBe(1)\n })\n\n test('notice and info logs are written to console.info', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.notice, args: ['notice'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.info, args: ['info'], timestamp: new Date() })\n\n expect(fakeConsole.infos.length).toBe(2)\n })\n\n\n test('debug, trace, and planck logs are written to console.debug', () => {\n const id = 'log'\n const reporter = createColorLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.debug, args: ['debug'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.trace, args: ['trace'], timestamp: new Date() })\n reporter.write({ id, level: logLevels.planck, args: ['planck'], timestamp: new Date() })\n\n expect(fakeConsole.debugs.length).toBe(3)\n })\n})\n\ndescribe('custom logs', () => {\n afterEach(() => clearCustomLogLevel())\n\n test('are written according to their log level value', () => {\n addCustomLogLevel('high', 50)\n addCustomLogLevel('important', 450)\n addCustomLogLevel('interest', 650)\n addCustomLogLevel('silly', 1000)\n\n const id = 'log'\n const reporter = createColorLogReporter()\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: 50, args: ['a'], timestamp: new Date() })\n reporter.write({ id, level: 450, args: ['b'], timestamp: new Date() })\n reporter.write({ id, level: 650, args: ['c'], timestamp: new Date() })\n reporter.write({ id, level: 1000, args: ['d'], timestamp: new Date() })\n\n expect(fakeConsole.errors.length).toBe(1)\n expect(fakeConsole.warns.length).toBe(1)\n expect(fakeConsole.infos.length).toBe(1)\n expect(fakeConsole.debugs.length).toBe(1)\n })\n})\n\nconst idFormatter: ConsoleLogFormatter = (entry) => [entry.id]\n\ndescribe('formatter', () => {\n test('use specific formatter', () => {\n const id = 'id-only'\n const reporter = createColorLogReporter({ formatter: idFormatter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\n })\n\n test('formatter can be changed afterward', () => {\n const id = 'id-only'\n const reporter = createColorLogReporter()\n reporter.formatter = idFormatter\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id, level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['id-only']])\n })\n})\n\ndescribe('filter', () => {\n const filter: LogFilter = (entry) => entry.id !== 'secret'\n test('use specific filter', () => {\n const reporter = createColorLogReporter({ formatter: idFormatter, filter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n reporter.write({ id: 'normal', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n reporter.write({ id: 'secret', level: logLevels.emergency, args: ['emergency'], timestamp: new Date() })\n\n expect(fakeConsole.errors).toEqual([['normal']])\n })\n})\n\ntest('write log entry with multiple arguments', () => {\n const id = 'log'\n const reporter = createColorLogReporter({ formatter: plainLogFormatter })\n const fakeConsole = reporter.console = createFakeConsole()\n\n const entry = { id, level: logLevels.info, args: ['a', 'b', 'c'], timestamp: new Date() }\n\n reporter.write(entry)\n\n expect(fakeConsole.infos).toEqual([\n [entry.timestamp.toISOString(), 'log', '(INFO)', 'a', 'b', 'c']\n ])\n})\n\nfunction createFakeConsole() {\n const errors: any[] = []\n const infos: any[] = []\n const warns: any[] = []\n const debugs: any[] = []\n return {\n errors,\n infos,\n warns,\n debugs,\n error(...args: any[]) { errors.push(args) },\n info(...args: any[]) { infos.push(args) },\n warn(...args: any[]) { warns.push(args) },\n debug(...args: any[]) { debugs.push(args) }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createColorLogReporter.spec.js","sourceRoot":"","sources":["../ts/createColorLogReporter.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAE5F,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACtC,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;QAC1C,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACrD,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAG,SAAiB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;QACpH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,iBAAiB,EAAE,GAAG,EAAE;QAC3B,MAAM,QAA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AS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,CAAC,CAAA;QAC3G,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE;IAClB,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAChC,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAA;QACzC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IACF,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC7B,MAAM,QAAQ,GAAG,sBAAsB,CAAC,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,CAAA;QAC9D,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { logLevels, plainLogFormatter } from 'standard-log'\nimport { createAnsiFormatter, createColorLogReporter, createCssFormatter } from './index.js'\n\ndescribe('rendering tests', () => {\n test('default to color rendering', () => {\n const reporter = createColorLogReporter();\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'color', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('plain rendering', () => {\n const reporter = createColorLogReporter({ formatter: plainLogFormatter });\n ['emergency', 'info', 'warn', 'debug'].forEach(level => {\n reporter.write({ id: 'plain', level: (logLevels as any)[level], args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n\n test('different timestamp settings', () => {\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n const reporter = createColorLogReporter({ formatter: createAnsiFormatter({ timestamp }) })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n test('different timestamp settings for css', () => {\n ['none', 'iso', 'elapsed'].forEach((timestamp: any) => {\n const reporter = createColorLogReporter({ formatter: createCssFormatter({ timestamp }) })\n reporter.write({ id: timestamp, level: logLevels.info, args: ['hello', 'world'], timestamp: new Date() })\n })\n })\n})\n\ndescribe('id', () => {\n test('default is \"console\"', () => {\n const reporter = createColorLogReporter()\n expect(reporter.id).toBe('console')\n })\n test('can be overridden', () => {\n const reporter = createColorLogReporter({ id: 'neo-console' })\n expect(reporter.id).toBe('neo-console')\n })\n})\n\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "standard-log-color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Color console reporter for `standard-log`",
|
|
5
5
|
"homepage": "https://github.com/unional/standard-log/tree/master/packages/color",
|
|
6
6
|
"bugs": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"bundle": "run-p bundle:es5 bundle:esm",
|
|
56
56
|
"bundle:es5": "webpack -c ./webpack.es5.cjs",
|
|
57
57
|
"bundle:esm": "webpack -c ./webpack.esm.cjs",
|
|
58
|
-
"clean": "rimraf dist lib libm
|
|
58
|
+
"clean": "rimraf cjs coverage dist esm lib libm tslib .tsbuildinfo && mkdir cjs && echo '{\"type\":\"commonjs\"}' > cjs/package.json || true",
|
|
59
59
|
"coverage": "jest --coverage",
|
|
60
60
|
"depcheck": "depcheck",
|
|
61
61
|
"lint": "cross-env TIMING=1 eslint --ext=ts,js,cjs,mjs .",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"webpack-cli": "^4.9.2"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"standard-log": ">=
|
|
96
|
+
"standard-log": ">=9.0.0"
|
|
97
97
|
},
|
|
98
98
|
"size-limit": [
|
|
99
99
|
{
|