@yamato-daiwa/es-extensions-nodejs 0.0.2 → 1.5.0-alpha.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/Distributable/ConsoleApplicationLogger.d.ts +47 -0
- package/Distributable/ConsoleApplicationLogger.js +416 -0
- package/Distributable/DateTime/NodeJS_Timer.d.ts +1 -1
- package/Distributable/DateTime/NodeJS_Timer.js +7 -4
- package/Distributable/index.d.ts +3 -3
- package/Distributable/index.js +11 -3
- package/README.md +5 -1
- package/package.json +20 -12
- package/tsconfig.test.json +0 -4
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ErrorLog, ThrownErrorLog, InfoLog, SuccessLog, WarningLog, Log, Logger } from "@yamato-daiwa/es-extensions";
|
|
2
|
+
declare abstract class ConsoleApplicationLogger {
|
|
3
|
+
private static localization;
|
|
4
|
+
static setLocalization(localization: Logger.Localization): typeof ConsoleApplicationLogger;
|
|
5
|
+
static throwErrorAndLog<CustomError extends Error>(errorLog: ThrownErrorLog<CustomError>): never;
|
|
6
|
+
static logError(errorLog: ErrorLog): void;
|
|
7
|
+
static logErrorLikeMessage(errorLikeLog: Log): void;
|
|
8
|
+
static logWarning(warningLog: WarningLog): void;
|
|
9
|
+
static logSuccess(successLog: SuccessLog): void;
|
|
10
|
+
static logInfo(infoLog: InfoLog): void;
|
|
11
|
+
static highlightText(targetString: string): string;
|
|
12
|
+
static generateConsoleMethodParametersForFormattedOutput(formattedOutputData: ConsoleApplicationLogger.FormattedOutputData): Array<string>;
|
|
13
|
+
static generateRedGreenBlueForegroundColorControlSequence(colorDefinition: ConsoleApplicationLogger.RedGreenBlue): string;
|
|
14
|
+
static generateRedGreenBlueBackgroundColorControlSequence(colorDefinition: ConsoleApplicationLogger.RedGreenBlue): string;
|
|
15
|
+
}
|
|
16
|
+
declare namespace ConsoleApplicationLogger {
|
|
17
|
+
type FormattedOutputData = Array<[string, Formatting]>;
|
|
18
|
+
type Formatting = {
|
|
19
|
+
foregroundColor?: FourBitColours | RedGreenBlue;
|
|
20
|
+
bold?: boolean;
|
|
21
|
+
bright?: boolean;
|
|
22
|
+
dim?: boolean;
|
|
23
|
+
underscore?: boolean;
|
|
24
|
+
blink?: boolean;
|
|
25
|
+
reverse?: boolean;
|
|
26
|
+
hidden?: boolean;
|
|
27
|
+
underlined?: boolean;
|
|
28
|
+
backgroundColor?: FourBitColours | RedGreenBlue;
|
|
29
|
+
};
|
|
30
|
+
enum FourBitColours {
|
|
31
|
+
black = "BLACK",
|
|
32
|
+
white = "WHITE",
|
|
33
|
+
red = "RED",
|
|
34
|
+
green = "GREEN",
|
|
35
|
+
blue = "BLUE",
|
|
36
|
+
yellow = "YELLOW",
|
|
37
|
+
magenta = "MAGENTA",
|
|
38
|
+
cyan = "CYAN"
|
|
39
|
+
}
|
|
40
|
+
type RedGreenBlue = {
|
|
41
|
+
red: number;
|
|
42
|
+
green: number;
|
|
43
|
+
blue: number;
|
|
44
|
+
};
|
|
45
|
+
function isRegGreenBlue(rawValue: unknown): rawValue is RedGreenBlue;
|
|
46
|
+
}
|
|
47
|
+
export default ConsoleApplicationLogger;
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const es_extensions_1 = require("@yamato-daiwa/es-extensions");
|
|
4
|
+
class ConsoleApplicationLogger {
|
|
5
|
+
static setLocalization(localization) {
|
|
6
|
+
ConsoleApplicationLogger.localization = localization;
|
|
7
|
+
return ConsoleApplicationLogger;
|
|
8
|
+
}
|
|
9
|
+
static throwErrorAndLog(errorLog) {
|
|
10
|
+
if ("errorInstance" in errorLog) {
|
|
11
|
+
errorLog.errorInstance.message = `${errorLog.title}\n${errorLog.errorInstance.message}` +
|
|
12
|
+
`\n\n${ConsoleApplicationLogger.localization.occurrenceLocation}: ${errorLog.occurrenceLocation}` +
|
|
13
|
+
`${(0, es_extensions_1.insertSubstringIf)(`\n\n${ConsoleApplicationLogger.localization.wrappableError}:` +
|
|
14
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(errorLog.wrappableError)}`, (0, es_extensions_1.isNotUndefined)(errorLog.wrappableError))}` +
|
|
15
|
+
`${(0, es_extensions_1.insertSubstringIf)(`\n\n${ConsoleApplicationLogger.localization.appendedData}:` +
|
|
16
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(errorLog.additionalData)}`, (0, es_extensions_1.isNotUndefined)(errorLog.additionalData))}` +
|
|
17
|
+
"\n";
|
|
18
|
+
throw errorLog.errorInstance;
|
|
19
|
+
}
|
|
20
|
+
const errorWillBeThrown = new Error(errorLog.description);
|
|
21
|
+
errorWillBeThrown.name = errorLog.errorType;
|
|
22
|
+
throw errorWillBeThrown;
|
|
23
|
+
}
|
|
24
|
+
static logError(errorLog) {
|
|
25
|
+
console.error(...ConsoleApplicationLogger.generateConsoleMethodParametersForFormattedOutput([
|
|
26
|
+
[
|
|
27
|
+
` ${errorLog.customBadgeText ?? ConsoleApplicationLogger.localization.badgesDefaultTitles.error} `,
|
|
28
|
+
{
|
|
29
|
+
bold: true,
|
|
30
|
+
foregroundColor: { red: 255, green: 255, blue: 255 },
|
|
31
|
+
backgroundColor: { red: 192, green: 57, blue: 43 }
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
` ${errorLog.title}\n`,
|
|
36
|
+
{
|
|
37
|
+
bold: true,
|
|
38
|
+
foregroundColor: { red: 192, green: 57, blue: 43 }
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
`${errorLog.description}`,
|
|
43
|
+
{
|
|
44
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
`\n\n${ConsoleApplicationLogger.localization.errorType}: `,
|
|
49
|
+
{
|
|
50
|
+
bold: true,
|
|
51
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
`${errorLog.errorType}`,
|
|
56
|
+
{
|
|
57
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
`\n${ConsoleApplicationLogger.localization.occurrenceLocation}: `,
|
|
62
|
+
{
|
|
63
|
+
bold: true,
|
|
64
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
...("caughtError" in errorLog ? [
|
|
68
|
+
[
|
|
69
|
+
`\n\n${ConsoleApplicationLogger.localization.caughtError}:`,
|
|
70
|
+
{
|
|
71
|
+
bold: true,
|
|
72
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
errorLog.caughtError instanceof Error ? `\n${errorLog.caughtError.stack}` :
|
|
77
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(errorLog.caughtError)}`,
|
|
78
|
+
{
|
|
79
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
] : []),
|
|
83
|
+
...("additionalData" in errorLog ? [
|
|
84
|
+
[
|
|
85
|
+
`\n\n${ConsoleApplicationLogger.localization.appendedData}:`,
|
|
86
|
+
{
|
|
87
|
+
bold: true,
|
|
88
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(errorLog.additionalData)}`,
|
|
93
|
+
{
|
|
94
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
] : [])
|
|
98
|
+
]));
|
|
99
|
+
}
|
|
100
|
+
static logErrorLikeMessage(errorLikeLog) {
|
|
101
|
+
console.error(...ConsoleApplicationLogger.generateConsoleMethodParametersForFormattedOutput([
|
|
102
|
+
[
|
|
103
|
+
` ${errorLikeLog.customBadgeText ?? ConsoleApplicationLogger.localization.badgesDefaultTitles.error} `,
|
|
104
|
+
{
|
|
105
|
+
bold: true,
|
|
106
|
+
foregroundColor: { red: 255, green: 255, blue: 255 },
|
|
107
|
+
backgroundColor: { red: 192, green: 57, blue: 43 }
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
` ${errorLikeLog.title}\n`,
|
|
112
|
+
{
|
|
113
|
+
bold: true,
|
|
114
|
+
foregroundColor: { red: 192, green: 57, blue: 43 }
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
`${errorLikeLog.description}`,
|
|
119
|
+
{
|
|
120
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
...("additionalData" in errorLikeLog ? [
|
|
124
|
+
[
|
|
125
|
+
`\n\n${ConsoleApplicationLogger.localization.appendedData}:`,
|
|
126
|
+
{
|
|
127
|
+
bold: true,
|
|
128
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(errorLikeLog.additionalData)}`,
|
|
133
|
+
{
|
|
134
|
+
foregroundColor: { red: 231, green: 76, blue: 60 }
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
] : [])
|
|
138
|
+
]));
|
|
139
|
+
}
|
|
140
|
+
static logWarning(warningLog) {
|
|
141
|
+
console.warn(...ConsoleApplicationLogger.generateConsoleMethodParametersForFormattedOutput([
|
|
142
|
+
[
|
|
143
|
+
` ${warningLog.customBadgeText ?? ConsoleApplicationLogger.localization.badgesDefaultTitles.warning} `,
|
|
144
|
+
{
|
|
145
|
+
bold: true,
|
|
146
|
+
foregroundColor: { red: 255, green: 255, blue: 255 },
|
|
147
|
+
backgroundColor: { red: 211, green: 84, blue: 0 }
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
` ${warningLog.title}\n`,
|
|
152
|
+
{
|
|
153
|
+
bold: true,
|
|
154
|
+
foregroundColor: { red: 211, green: 84, blue: 0 }
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
`${warningLog.description}`,
|
|
159
|
+
{
|
|
160
|
+
foregroundColor: { red: 230, green: 126, blue: 34 }
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
...("occurrenceLocation" in warningLog ? [
|
|
164
|
+
[
|
|
165
|
+
`\n\n${ConsoleApplicationLogger.localization.occurrenceLocation}: `,
|
|
166
|
+
{
|
|
167
|
+
bold: true,
|
|
168
|
+
foregroundColor: { red: 230, green: 126, blue: 34 }
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
[
|
|
172
|
+
`${warningLog.occurrenceLocation}`,
|
|
173
|
+
{
|
|
174
|
+
foregroundColor: { red: 230, green: 126, blue: 34 }
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
] : []),
|
|
178
|
+
...("additionalData" in warningLog ? [
|
|
179
|
+
[
|
|
180
|
+
`\n\n${ConsoleApplicationLogger.localization.appendedData}:`,
|
|
181
|
+
{
|
|
182
|
+
"font-weight": "bold",
|
|
183
|
+
foregroundColor: { red: 230, green: 126, blue: 34 }
|
|
184
|
+
}
|
|
185
|
+
],
|
|
186
|
+
[
|
|
187
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(warningLog.additionalData)}`,
|
|
188
|
+
{
|
|
189
|
+
foregroundColor: { red: 230, green: 126, blue: 34 }
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
] : [])
|
|
193
|
+
]));
|
|
194
|
+
}
|
|
195
|
+
static logSuccess(successLog) {
|
|
196
|
+
console.log(...ConsoleApplicationLogger.generateConsoleMethodParametersForFormattedOutput([
|
|
197
|
+
[
|
|
198
|
+
` ${successLog.customBadgeText ?? ConsoleApplicationLogger.localization.badgesDefaultTitles.success} `,
|
|
199
|
+
{
|
|
200
|
+
bold: true,
|
|
201
|
+
foregroundColor: { red: 255, green: 255, blue: 255 },
|
|
202
|
+
backgroundColor: { red: 39, green: 174, blue: 96 }
|
|
203
|
+
}
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
` ${successLog.title}\n`,
|
|
207
|
+
{
|
|
208
|
+
bold: true,
|
|
209
|
+
foregroundColor: { red: 39, green: 174, blue: 96 }
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
[
|
|
213
|
+
`${successLog.description}`,
|
|
214
|
+
{
|
|
215
|
+
foregroundColor: { red: 46, green: 204, blue: 113 }
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
...("additionalData" in successLog ? [
|
|
219
|
+
[
|
|
220
|
+
`\n\n${ConsoleApplicationLogger.localization.appendedData}:`,
|
|
221
|
+
{
|
|
222
|
+
bold: true,
|
|
223
|
+
foregroundColor: { red: 46, green: 204, blue: 113 }
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
[
|
|
227
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(successLog.additionalData)}`,
|
|
228
|
+
{
|
|
229
|
+
foregroundColor: { red: 46, green: 204, blue: 113 }
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
] : [])
|
|
233
|
+
]));
|
|
234
|
+
}
|
|
235
|
+
static logInfo(infoLog) {
|
|
236
|
+
console.log(...ConsoleApplicationLogger.generateConsoleMethodParametersForFormattedOutput([
|
|
237
|
+
[
|
|
238
|
+
` ${infoLog.customBadgeText ?? ConsoleApplicationLogger.localization.badgesDefaultTitles.info} `,
|
|
239
|
+
{
|
|
240
|
+
bold: true,
|
|
241
|
+
foregroundColor: { red: 255, green: 255, blue: 255 },
|
|
242
|
+
backgroundColor: { red: 41, green: 128, blue: 185 }
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
` ${infoLog.title}\n`,
|
|
247
|
+
{
|
|
248
|
+
foregroundColor: { red: 41, green: 128, blue: 185 },
|
|
249
|
+
bold: true
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
[
|
|
253
|
+
`${infoLog.description}`,
|
|
254
|
+
{
|
|
255
|
+
foregroundColor: { red: 52, green: 152, blue: 219 }
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
...("additionalData" in infoLog ? [
|
|
259
|
+
[
|
|
260
|
+
`\n\n${ConsoleApplicationLogger.localization.appendedData}:`,
|
|
261
|
+
{
|
|
262
|
+
bold: true,
|
|
263
|
+
foregroundColor: { red: 52, green: 152, blue: 219 }
|
|
264
|
+
}
|
|
265
|
+
],
|
|
266
|
+
[
|
|
267
|
+
`\n${(0, es_extensions_1.stringifyAndFormatArbitraryValue)(infoLog.additionalData)}`,
|
|
268
|
+
{
|
|
269
|
+
foregroundColor: { red: 52, green: 152, blue: 219 }
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
] : [])
|
|
273
|
+
]));
|
|
274
|
+
}
|
|
275
|
+
static highlightText(targetString) {
|
|
276
|
+
return `\x1b[43m${targetString}\x1b[0m`;
|
|
277
|
+
}
|
|
278
|
+
static generateConsoleMethodParametersForFormattedOutput(formattedOutputData) {
|
|
279
|
+
const logsTextings = [];
|
|
280
|
+
const templatesWithFormattings = [];
|
|
281
|
+
for (const singleFormattedOutputData of formattedOutputData) {
|
|
282
|
+
let templateWithFormatting = "";
|
|
283
|
+
const formatting = singleFormattedOutputData[1];
|
|
284
|
+
switch (formatting.foregroundColor) {
|
|
285
|
+
case ConsoleApplicationLogger.FourBitColours.black: {
|
|
286
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[30m`;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case ConsoleApplicationLogger.FourBitColours.red: {
|
|
290
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[31m`;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case ConsoleApplicationLogger.FourBitColours.green: {
|
|
294
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[32m`;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
case ConsoleApplicationLogger.FourBitColours.yellow: {
|
|
298
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[33m`;
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
case ConsoleApplicationLogger.FourBitColours.blue: {
|
|
302
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[34m`;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
case ConsoleApplicationLogger.FourBitColours.magenta: {
|
|
306
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[35m`;
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
case ConsoleApplicationLogger.FourBitColours.cyan: {
|
|
310
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[36m`;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case ConsoleApplicationLogger.FourBitColours.white: {
|
|
314
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[37m`;
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
default: {
|
|
318
|
+
if (ConsoleApplicationLogger.isRegGreenBlue(formatting.foregroundColor)) {
|
|
319
|
+
templateWithFormatting = `${templateWithFormatting}${ConsoleApplicationLogger.generateRedGreenBlueForegroundColorControlSequence(formatting.foregroundColor)}`;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
switch (formatting.backgroundColor) {
|
|
324
|
+
case ConsoleApplicationLogger.FourBitColours.black: {
|
|
325
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[40m`;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case ConsoleApplicationLogger.FourBitColours.red: {
|
|
329
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[41m`;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
case ConsoleApplicationLogger.FourBitColours.green: {
|
|
333
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[42m`;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
case ConsoleApplicationLogger.FourBitColours.yellow: {
|
|
337
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[43m`;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
case ConsoleApplicationLogger.FourBitColours.blue: {
|
|
341
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[44m`;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case ConsoleApplicationLogger.FourBitColours.magenta: {
|
|
345
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[45m`;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
case ConsoleApplicationLogger.FourBitColours.cyan: {
|
|
349
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[46m`;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case ConsoleApplicationLogger.FourBitColours.white: {
|
|
353
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[47m`;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
default: {
|
|
357
|
+
if (ConsoleApplicationLogger.isRegGreenBlue(formatting.backgroundColor)) {
|
|
358
|
+
templateWithFormatting = `${templateWithFormatting}${ConsoleApplicationLogger.generateRedGreenBlueBackgroundColorControlSequence(formatting.backgroundColor)}`;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (formatting.bold === true) {
|
|
363
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[1m`;
|
|
364
|
+
}
|
|
365
|
+
if (formatting.underlined === true || formatting.underscore === true) {
|
|
366
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[4m`;
|
|
367
|
+
}
|
|
368
|
+
if (formatting.bright === true) {
|
|
369
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[1m`;
|
|
370
|
+
}
|
|
371
|
+
if (formatting.dim === true) {
|
|
372
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[2m`;
|
|
373
|
+
}
|
|
374
|
+
if (formatting.blink === true) {
|
|
375
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[5m`;
|
|
376
|
+
}
|
|
377
|
+
if (formatting.reverse === true) {
|
|
378
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[7m`;
|
|
379
|
+
}
|
|
380
|
+
if (formatting.hidden === true) {
|
|
381
|
+
templateWithFormatting = `${templateWithFormatting}\x1b[8m`;
|
|
382
|
+
}
|
|
383
|
+
logsTextings.push(singleFormattedOutputData[0]);
|
|
384
|
+
templatesWithFormattings.push(templateWithFormatting);
|
|
385
|
+
}
|
|
386
|
+
return [`${templatesWithFormattings.join("%s\x1b[0m")}%s\x1b[0m`].concat(logsTextings);
|
|
387
|
+
}
|
|
388
|
+
static generateRedGreenBlueForegroundColorControlSequence(colorDefinition) {
|
|
389
|
+
return `\x1b[38;2;${colorDefinition.red};${colorDefinition.green};${colorDefinition.blue}m`;
|
|
390
|
+
}
|
|
391
|
+
static generateRedGreenBlueBackgroundColorControlSequence(colorDefinition) {
|
|
392
|
+
return `\x1b[48;2;${colorDefinition.red};${colorDefinition.green};${colorDefinition.blue}m`;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
ConsoleApplicationLogger.localization = es_extensions_1.LoggerLocalization__English;
|
|
396
|
+
(function (ConsoleApplicationLogger) {
|
|
397
|
+
let FourBitColours;
|
|
398
|
+
(function (FourBitColours) {
|
|
399
|
+
FourBitColours["black"] = "BLACK";
|
|
400
|
+
FourBitColours["white"] = "WHITE";
|
|
401
|
+
FourBitColours["red"] = "RED";
|
|
402
|
+
FourBitColours["green"] = "GREEN";
|
|
403
|
+
FourBitColours["blue"] = "BLUE";
|
|
404
|
+
FourBitColours["yellow"] = "YELLOW";
|
|
405
|
+
FourBitColours["magenta"] = "MAGENTA";
|
|
406
|
+
FourBitColours["cyan"] = "CYAN";
|
|
407
|
+
})(FourBitColours = ConsoleApplicationLogger.FourBitColours || (ConsoleApplicationLogger.FourBitColours = {}));
|
|
408
|
+
function isRegGreenBlue(rawValue) {
|
|
409
|
+
return (0, es_extensions_1.isArbitraryObject)(rawValue) &&
|
|
410
|
+
(0, es_extensions_1.isNonNegativeInteger)(rawValue.red) &&
|
|
411
|
+
(0, es_extensions_1.isNonNegativeInteger)(rawValue.green) &&
|
|
412
|
+
(0, es_extensions_1.isNonNegativeInteger)(rawValue.blue);
|
|
413
|
+
}
|
|
414
|
+
ConsoleApplicationLogger.isRegGreenBlue = isRegGreenBlue;
|
|
415
|
+
})(ConsoleApplicationLogger || (ConsoleApplicationLogger = {}));
|
|
416
|
+
exports.default = ConsoleApplicationLogger;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const es_extensions_1 = require("@yamato-daiwa/es-extensions");
|
|
4
|
+
class NodeJS_Timer extends es_extensions_1.Timer {
|
|
3
5
|
start() {
|
|
4
|
-
this.
|
|
6
|
+
this.nativeTimeout = setTimeout(this.onElapsed.bind(this), (0, es_extensions_1.secondsToMilliseconds)(this.period__seconds));
|
|
5
7
|
}
|
|
6
8
|
stop() {
|
|
7
|
-
clearTimeout(this.
|
|
9
|
+
clearTimeout(this.nativeTimeout);
|
|
8
10
|
}
|
|
9
11
|
restart() {
|
|
10
12
|
this.stop();
|
|
11
13
|
this.start();
|
|
12
14
|
}
|
|
13
15
|
}
|
|
16
|
+
exports.default = NodeJS_Timer;
|
package/Distributable/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @yamato-daiwa/es-extensions-nodejs
|
|
2
|
+
* @yamato-daiwa/es-extensions-nodejs v1.5
|
|
3
3
|
* (c) 2021 Sole proprietorship "Yamato Daiwa" Takeshi Tokugawa
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export {
|
|
6
|
+
export { default as NodeJS_Timer } from "./DateTime/NodeJS_Timer";
|
|
7
|
+
export { default as ConsoleApplicationLogger } from "./ConsoleApplicationLogger";
|
package/Distributable/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/*!
|
|
2
|
-
* @yamato-daiwa/es-extensions-nodejs
|
|
3
|
+
* @yamato-daiwa/es-extensions-nodejs v1.5
|
|
3
4
|
* (c) 2021 Sole proprietorship "Yamato Daiwa" Takeshi Tokugawa
|
|
4
5
|
* Released under the MIT License.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ConsoleApplicationLogger = exports.NodeJS_Timer = void 0;
|
|
12
|
+
var NodeJS_Timer_1 = require("./DateTime/NodeJS_Timer");
|
|
13
|
+
Object.defineProperty(exports, "NodeJS_Timer", { enumerable: true, get: function () { return __importDefault(NodeJS_Timer_1).default; } });
|
|
14
|
+
var ConsoleApplicationLogger_1 = require("./ConsoleApplicationLogger");
|
|
15
|
+
Object.defineProperty(exports, "ConsoleApplicationLogger", { enumerable: true, get: function () { return __importDefault(ConsoleApplicationLogger_1).default; } });
|
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @yamato-daiwa/es-extensions-nodejs
|
|
2
2
|
|
|
3
|
+
[]()
|
|
4
|
+
[]()
|
|
5
|
+
[](https://www.npmjs.com/package/@yamato-daiwa/es-extensions-nodejs)
|
|
6
|
+
|
|
3
7
|
Additional to [@yamato-daiwa/es-extensions](https://www.npmjs.com/package/@yamato-daiwa/es-extensions) functionality
|
|
4
8
|
for Node.js environment. Helper functions and classes aimed to reduce the routine code.
|
|
5
9
|
Build-in TypeScript type safety without `any` type.
|
|
@@ -8,5 +12,5 @@ Build-in TypeScript type safety without `any` type.
|
|
|
8
12
|
## Installation
|
|
9
13
|
|
|
10
14
|
```
|
|
11
|
-
npm i @yamato-daiwa/es-extensions-nodejs -E
|
|
15
|
+
npm i @yamato-daiwa/es-extensions-nodejs @yamato-daiwa/es-extensions -E
|
|
12
16
|
```
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamato-daiwa/es-extensions-nodejs",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.5.0-alpha.0",
|
|
4
4
|
"description": "Additional to @yamato-daiwa/es-extensions functionality for Node.js environment. Helper functions and classes aimed to reduce the routine code. Build-in TypeScript type safety.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nodejs",
|
|
7
|
+
"typescript",
|
|
7
8
|
"utils",
|
|
8
9
|
"logger"
|
|
9
10
|
],
|
|
@@ -14,29 +15,36 @@
|
|
|
14
15
|
"license": "MIT",
|
|
15
16
|
"repository": {
|
|
16
17
|
"type": "git",
|
|
17
|
-
"url": "https://github.com/TokugawaTakeshi/
|
|
18
|
+
"url": "https://github.com/TokugawaTakeshi/Yamato-Daiwa-ES-Extensions.git"
|
|
18
19
|
},
|
|
19
20
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/TokugawaTakeshi/
|
|
21
|
+
"url": "https://github.com/TokugawaTakeshi/Yamato-Daiwa-ES-Extensions.git/issues",
|
|
21
22
|
"email": "tokugawa.takesi@gmail.com"
|
|
22
23
|
},
|
|
23
24
|
"main": "./Distributable/index.js",
|
|
24
25
|
"types": "./Distributable/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"Distributable"
|
|
28
|
+
],
|
|
25
29
|
"devDependencies": {
|
|
26
|
-
"@types/
|
|
27
|
-
"@types/
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"@types/json5": "0.0.30",
|
|
31
|
+
"@types/mocha": "9.1.0",
|
|
32
|
+
"@types/node": "16.10.2",
|
|
33
|
+
"del-cli": "4.0.1",
|
|
34
|
+
"mocha": "9.2.2",
|
|
35
|
+
"ts-node": "10.7.0",
|
|
36
|
+
"typescript": "4.4.3",
|
|
37
|
+
"yamato-daiwa_code_quality_management": "0.2.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@yamato-daiwa/es-extensions": "1.4.5",
|
|
41
|
+
"json5": "2.2.0"
|
|
32
42
|
},
|
|
33
43
|
"engines": {
|
|
34
44
|
"node": ">=10.4.0"
|
|
35
45
|
},
|
|
36
46
|
"scripts": {
|
|
47
|
+
"Rebuild distributable": "rimraf Distributable & tsc",
|
|
37
48
|
"Lint": "eslint Source Tests"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@yamato-daiwa/es-extensions": "1.0.1"
|
|
41
49
|
}
|
|
42
50
|
}
|
package/tsconfig.test.json
DELETED