@strapi/logger 0.0.0-next.fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a → 0.0.0-next.fc1775f7731f8999840e56e298a216b9a6c5c4ad
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/LICENSE +18 -3
- package/dist/configs/default-configuration.d.ts +1 -0
- package/dist/configs/default-configuration.d.ts.map +1 -0
- package/dist/configs/index.d.ts +1 -0
- package/dist/configs/index.d.ts.map +1 -0
- package/dist/configs/output-file-configuration.d.ts +3 -2
- package/dist/configs/output-file-configuration.d.ts.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/formats/detailed-log.d.ts +7 -0
- package/dist/formats/detailed-log.d.ts.map +1 -0
- package/dist/formats/exclude-colors.d.ts +1 -0
- package/dist/formats/exclude-colors.d.ts.map +1 -0
- package/dist/formats/index.d.ts +4 -1
- package/dist/formats/index.d.ts.map +1 -0
- package/dist/formats/level-filter.d.ts +1 -0
- package/dist/formats/level-filter.d.ts.map +1 -0
- package/dist/formats/log-errors.d.ts +1 -0
- package/dist/formats/log-errors.d.ts.map +1 -0
- package/dist/formats/pretty-print.d.ts +1 -0
- package/dist/formats/pretty-print.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +116 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +13 -12
- package/dist/configs/default-configuration.js +0 -14
- package/dist/configs/default-configuration.js.map +0 -1
- package/dist/configs/index.js +0 -11
- package/dist/configs/index.js.map +0 -1
- package/dist/configs/output-file-configuration.js +0 -17
- package/dist/configs/output-file-configuration.js.map +0 -1
- package/dist/constants.js +0 -11
- package/dist/constants.js.map +0 -1
- package/dist/formats/exclude-colors.js +0 -16
- package/dist/formats/exclude-colors.js.map +0 -1
- package/dist/formats/index.js +0 -13
- package/dist/formats/index.js.map +0 -1
- package/dist/formats/level-filter.js +0 -7
- package/dist/formats/level-filter.js.map +0 -1
- package/dist/formats/log-errors.js +0 -11
- package/dist/formats/log-errors.js.map +0 -1
- package/dist/formats/pretty-print.js +0 -30
- package/dist/formats/pretty-print.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -2,7 +2,21 @@ Copyright (c) 2015-present Strapi Solutions SAS
|
|
|
2
2
|
|
|
3
3
|
Portions of the Strapi software are licensed as follows:
|
|
4
4
|
|
|
5
|
-
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined below.
|
|
6
|
+
|
|
7
|
+
Enterprise License
|
|
8
|
+
|
|
9
|
+
If you or the company you represent has entered into a written agreement referencing the Enterprise Edition of the Strapi source code available at
|
|
10
|
+
https://github.com/strapi/strapi, then such agreement applies to your use of the Enterprise Edition of the Strapi Software. If you or the company you
|
|
11
|
+
represent is using the Enterprise Edition of the Strapi Software in connection with a subscription to our cloud offering, then the agreement you have
|
|
12
|
+
agreed to with respect to our cloud offering and the licenses included in such agreement apply to your use of the Enterprise Edition of the Strapi Software.
|
|
13
|
+
Otherwise, the Strapi Enterprise Software License Agreement (found here https://strapi.io/enterprise-terms) applies to your use of the Enterprise Edition of the Strapi Software.
|
|
14
|
+
|
|
15
|
+
BY ACCESSING OR USING THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE RELEVANT REFERENCED AGREEMENT.
|
|
16
|
+
IF YOU ARE NOT AUTHORIZED TO ACCEPT THESE TERMS ON BEHALF OF THE COMPANY YOU REPRESENT OR IF YOU DO NOT AGREE TO ALL OF THE RELEVANT TERMS AND CONDITIONS REFERENCED AND YOU
|
|
17
|
+
HAVE NOT OTHERWISE EXECUTED A WRITTEN AGREEMENT WITH STRAPI, YOU ARE NOT AUTHORIZED TO ACCESS OR USE OR ALLOW ANY USER TO ACCESS OR USE ANY PART OF
|
|
18
|
+
THE ENTERPRISE EDITION OF THE STRAPI SOFTWARE. YOUR ACCESS RIGHTS ARE CONDITIONAL ON YOUR CONSENT TO THE RELEVANT REFERENCED TERMS TO THE EXCLUSION OF ALL OTHER TERMS;
|
|
19
|
+
IF THE RELEVANT REFERENCED TERMS ARE CONSIDERED AN OFFER BY YOU, ACCEPTANCE IS EXPRESSLY LIMITED TO THE RELEVANT REFERENCED TERMS.
|
|
6
20
|
|
|
7
21
|
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
22
|
|
|
@@ -18,5 +32,6 @@ furnished to do so, subject to the following conditions:
|
|
|
18
32
|
The above copyright notice and this permission notice shall be included in all
|
|
19
33
|
copies or substantial portions of the Software.
|
|
20
34
|
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
36
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
37
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-configuration.d.ts","sourceRoot":"","sources":["../../src/configs/default-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,SAAS,CAAC;8BAIjC,aAAa;AAAhC,wBAOE"}
|
package/dist/configs/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { LoggerOptions } from 'winston';
|
|
2
|
-
declare const _default: (filename: string) => LoggerOptions;
|
|
1
|
+
import { transports, LoggerOptions } from 'winston';
|
|
2
|
+
declare const _default: (filename: string, fileTransportOptions?: transports.FileTransportOptions) => LoggerOptions;
|
|
3
3
|
export default _default;
|
|
4
|
+
//# sourceMappingURL=output-file-configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-file-configuration.d.ts","sourceRoot":"","sources":["../../src/configs/output-file-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;mCAMxC,MAAM,yBACM,WAAW,oBAAoB,KACpD,aAAa;AAHhB,wBAkBE"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,QAAA,MAAM,MAAM,2BAAoB,CAAC;AACjC,QAAA,MAAM,WAAW,UAAU,CAAC;AAC5B,QAAA,MAAM,KAAK,QAAsB,CAAC;AAElC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detailed-log.d.ts","sourceRoot":"","sources":["../../src/formats/detailed-log.ts"],"names":[],"mappings":"AAEA;;;GAGG;;AACH,wBAYG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclude-colors.d.ts","sourceRoot":"","sources":["../../src/formats/exclude-colors.ts"],"names":[],"mappings":"AAEA;;;GAGG;;AACH,wBAUG"}
|
package/dist/formats/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export { default as prettyPrint
|
|
1
|
+
export { default as prettyPrint } from './pretty-print';
|
|
2
|
+
export type { PrettyPrintOptions } from './pretty-print';
|
|
2
3
|
export { default as levelFilter } from './level-filter';
|
|
3
4
|
export { default as excludeColors } from './exclude-colors';
|
|
5
|
+
export { default as detailedLogs } from './detailed-log';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/formats/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level-filter.d.ts","sourceRoot":"","sources":["../../src/formats/level-filter.ts"],"names":[],"mappings":"oCAE2B,MAAM,EAAE;AAAnC,wBAEE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-errors.d.ts","sourceRoot":"","sources":["../../src/formats/log-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAE1C,QAAA,MAAM,SAAS,EAAE,OAAO,CAAC,UAMvB,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-print.d.ts","sourceRoot":"","sources":["../../src/formats/pretty-print.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAK1C,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC;IAC1D;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;mCACsB,kBAAkB,KAAQ,QAAQ,MAAM;AAAjE,wBA0BE"}
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAEpC,QAAA,MAAM,YAAY,uBAAuB,QAAQ,aAAa,KAAQ,cAMrE,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,123 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const winston = require("winston");
|
|
4
|
+
function _interopNamespace(e) {
|
|
5
|
+
if (e && e.__esModule) return e;
|
|
6
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
+
if (e) {
|
|
8
|
+
for (const k in e) {
|
|
9
|
+
if (k !== "default") {
|
|
10
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => e[k]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
7
16
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
const winston__namespace = /* @__PURE__ */ _interopNamespace(winston);
|
|
22
|
+
const LEVELS = winston.config.npm.levels;
|
|
23
|
+
const LEVEL_LABEL = "silly";
|
|
24
|
+
LEVELS[LEVEL_LABEL];
|
|
25
|
+
const logErrors = winston.format((info) => {
|
|
26
|
+
if (info instanceof Error) {
|
|
27
|
+
return { ...info, message: `${info.message}${info.stack ? `
|
|
28
|
+
${info.stack}` : ""}` };
|
|
29
|
+
}
|
|
30
|
+
return info;
|
|
17
31
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
const defaultTimestampFormat = "YYYY-MM-DD HH:mm:ss.SSS";
|
|
33
|
+
const prettyPrint = (options = {}) => {
|
|
34
|
+
const { timestamps = true, colors = true } = options;
|
|
35
|
+
const handlers = [];
|
|
36
|
+
if (timestamps) {
|
|
37
|
+
handlers.push(
|
|
38
|
+
winston.format.timestamp({
|
|
39
|
+
format: timestamps === true ? defaultTimestampFormat : timestamps
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
if (colors) {
|
|
44
|
+
handlers.push(winston.format.colorize());
|
|
45
|
+
}
|
|
46
|
+
handlers.push(logErrors());
|
|
47
|
+
handlers.push(
|
|
48
|
+
winston.format.printf(({ level, message, timestamp }) => {
|
|
49
|
+
return `${timestamps ? `[${timestamp}] ` : ""}${level}: ${message}`;
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
return winston.format.combine(...handlers);
|
|
24
53
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
const levelFilter = (...levels) => {
|
|
55
|
+
return winston.format((info) => levels.some((level) => info.level.includes(level)) ? info : false)();
|
|
56
|
+
};
|
|
57
|
+
const excludeColors = winston.format.printf(({ message }) => {
|
|
58
|
+
if (typeof message !== "string") {
|
|
59
|
+
return message;
|
|
60
|
+
}
|
|
61
|
+
return message.replace(
|
|
62
|
+
// eslint-disable-next-line no-control-regex
|
|
63
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
64
|
+
""
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
const detailedLog = winston.format.printf(({ message, level, timestamp }) => {
|
|
68
|
+
if (typeof message !== "string") {
|
|
69
|
+
return message;
|
|
70
|
+
}
|
|
71
|
+
const newMessage = `[${timestamp}] ${level}: ${message}`;
|
|
72
|
+
return newMessage.replace(
|
|
73
|
+
// eslint-disable-next-line no-control-regex
|
|
74
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
75
|
+
""
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
79
|
+
__proto__: null,
|
|
80
|
+
detailedLogs: detailedLog,
|
|
81
|
+
excludeColors,
|
|
82
|
+
levelFilter,
|
|
83
|
+
prettyPrint
|
|
84
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
85
|
+
const defaultConfiguration = () => {
|
|
86
|
+
return {
|
|
87
|
+
level: LEVEL_LABEL,
|
|
88
|
+
levels: LEVELS,
|
|
89
|
+
format: prettyPrint(),
|
|
90
|
+
transports: [new winston.transports.Console()]
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const outputFileConfiguration = (filename, fileTransportOptions = {}) => {
|
|
94
|
+
return {
|
|
95
|
+
level: LEVEL_LABEL,
|
|
96
|
+
levels: LEVELS,
|
|
97
|
+
format: prettyPrint(),
|
|
98
|
+
transports: [
|
|
99
|
+
new winston.transports.Console(),
|
|
100
|
+
new winston.transports.File({
|
|
101
|
+
level: "error",
|
|
102
|
+
filename,
|
|
103
|
+
format: excludeColors,
|
|
104
|
+
...fileTransportOptions
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
110
|
+
__proto__: null,
|
|
111
|
+
createDefaultConfiguration: defaultConfiguration,
|
|
112
|
+
createOutputFileConfiguration: outputFileConfiguration
|
|
113
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
32
114
|
const createLogger = (userConfiguration = {}) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
115
|
+
const configuration = defaultConfiguration();
|
|
116
|
+
Object.assign(configuration, userConfiguration);
|
|
117
|
+
return winston__namespace.createLogger(configuration);
|
|
36
118
|
};
|
|
119
|
+
exports.winston = winston__namespace;
|
|
120
|
+
exports.configs = index;
|
|
37
121
|
exports.createLogger = createLogger;
|
|
38
|
-
|
|
122
|
+
exports.formats = index$1;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/constants.ts","../src/formats/log-errors.ts","../src/formats/pretty-print.ts","../src/formats/level-filter.ts","../src/formats/exclude-colors.ts","../src/formats/detailed-log.ts","../src/configs/default-configuration.ts","../src/configs/output-file-configuration.ts","../src/index.ts"],"sourcesContent":["import { config } from 'winston';\n\nconst LEVELS = config.npm.levels;\nconst LEVEL_LABEL = 'silly';\nconst LEVEL = LEVELS[LEVEL_LABEL];\n\nexport { LEVEL, LEVEL_LABEL, LEVELS };\n","import { format, Logform } from 'winston';\n\nconst logErrors: Logform.FormatWrap = format((info) => {\n if (info instanceof Error) {\n return { ...info, message: `${info.message as string}${info.stack ? `\\n${info.stack}` : ''}` };\n }\n\n return info;\n});\n\nexport default logErrors;\n","import { format, Logform } from 'winston';\nimport logErrors from './log-errors';\n\nconst defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';\n\nexport interface PrettyPrintOptions {\n /**\n * Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string\n */\n timestamps?: Logform.TimestampOptions['format'] | boolean;\n /**\n * Enable or disable the use of colors for the log level\n */\n colors?: boolean;\n}\n\n/**\n * Create a pretty print formatter for a winston logger\n * @param options\n */\nexport default (options: PrettyPrintOptions = {}): Logform.Format => {\n const { timestamps = true, colors = true } = options;\n\n const handlers: Logform.Format[] = [];\n\n if (timestamps) {\n handlers.push(\n format.timestamp({\n format: timestamps === true ? defaultTimestampFormat : timestamps,\n })\n );\n }\n\n if (colors) {\n handlers.push(format.colorize());\n }\n\n handlers.push(logErrors());\n\n handlers.push(\n format.printf(({ level, message, timestamp }) => {\n return `${timestamps ? `[${timestamp as string}] ` : ''}${level}: ${message as string}`;\n })\n );\n\n return format.combine(...handlers);\n};\n","import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n return message.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message, level, timestamp }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n const newMessage = `[${timestamp as string}] ${level}: ${message as string}`;\n\n return newMessage.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { transports, LoggerOptions } from 'winston';\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint } from '../formats';\n\nexport default (): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [new transports.Console()],\n };\n};\n","import { transports, LoggerOptions } from 'winston';\n\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint, excludeColors } from '../formats';\n\nexport default (\n filename: string,\n fileTransportOptions: transports.FileTransportOptions = {}\n): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({\n level: 'error',\n filename,\n format: excludeColors,\n ...fileTransportOptions,\n }),\n ],\n };\n};\n","import * as winston from 'winston';\nimport * as configs from './configs';\n\nexport * as formats from './formats';\n\nexport type Logger = winston.Logger;\n\nconst createLogger = (userConfiguration: winston.LoggerOptions = {}): winston.Logger => {\n const configuration = configs.createDefaultConfiguration();\n\n Object.assign(configuration, userConfiguration);\n\n return winston.createLogger(configuration);\n};\n\nexport { createLogger, winston, configs };\n"],"names":["config","format","transports","configs.createDefaultConfiguration","winston"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,SAASA,QAAAA,OAAO,IAAI;AAC1B,MAAM,cAAc;AACN,OAAO,WAAW;ACFhC,MAAM,YAAgCC,QAAAA,OAAO,CAAC,SAAS;AACrD,MAAI,gBAAgB,OAAO;AAClB,WAAA,EAAE,GAAG,MAAM,SAAS,GAAG,KAAK,OAAiB,GAAG,KAAK,QAAQ;AAAA,EAAK,KAAK,KAAK,KAAK,EAAE,GAAG;AAAA,EAAA;AAGxF,SAAA;AACT,CAAC;ACLD,MAAM,yBAAyB;AAiB/B,MAAA,cAAe,CAAC,UAA8B,CAAA,MAAuB;AACnE,QAAM,EAAE,aAAa,MAAM,SAAS,KAAS,IAAA;AAE7C,QAAM,WAA6B,CAAC;AAEpC,MAAI,YAAY;AACL,aAAA;AAAA,MACPA,QAAAA,OAAO,UAAU;AAAA,QACf,QAAQ,eAAe,OAAO,yBAAyB;AAAA,MACxD,CAAA;AAAA,IACH;AAAA,EAAA;AAGF,MAAI,QAAQ;AACD,aAAA,KAAKA,eAAO,UAAU;AAAA,EAAA;AAGxB,WAAA,KAAK,WAAW;AAEhB,WAAA;AAAA,IACPA,eAAO,OAAO,CAAC,EAAE,OAAO,SAAS,gBAAgB;AACxC,aAAA,GAAG,aAAa,IAAI,SAAmB,OAAO,EAAE,GAAG,KAAK,KAAK,OAAiB;AAAA,IACtF,CAAA;AAAA,EACH;AAEO,SAAAA,QAAA,OAAO,QAAQ,GAAG,QAAQ;AACnC;AC5CA,MAAe,cAAA,IAAI,WAAqB;AACtC,SAAOA,QAAO,OAAA,CAAC,SAAU,OAAO,KAAK,CAAC,UAAU,KAAK,MAAM,SAAS,KAAK,CAAC,IAAI,OAAO,KAAM,EAAE;AAC/F;ACEA,MAAeA,gBAAAA,QAAAA,OAAO,OAAO,CAAC,EAAE,cAAc;AACxC,MAAA,OAAO,YAAY,UAAU;AACxB,WAAA;AAAA,EAAA;AAGT,SAAO,QAAQ;AAAA;AAAA,IAEb;AAAA,IACA;AAAA,EACF;AACF,CAAC;ACVD,MAAA,cAAeA,eAAO,OAAO,CAAC,EAAE,SAAS,OAAO,gBAAgB;AAC1D,MAAA,OAAO,YAAY,UAAU;AACxB,WAAA;AAAA,EAAA;AAGT,QAAM,aAAa,IAAI,SAAmB,KAAK,KAAK,KAAK,OAAiB;AAE1E,SAAO,WAAW;AAAA;AAAA,IAEhB;AAAA,IACA;AAAA,EACF;AACF,CAAC;;;;;;;;ACdD,MAAA,uBAAe,MAAqB;AAC3B,SAAA;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ,YAAY;AAAA,IACpB,YAAY,CAAC,IAAIC,QAAA,WAAW,QAAS,CAAA;AAAA,EACvC;AACF;ACNA,MAAA,0BAAe,CACb,UACA,uBAAwD,OACtC;AACX,SAAA;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ,YAAY;AAAA,IACpB,YAAY;AAAA,MACV,IAAIA,QAAAA,WAAW,QAAQ;AAAA,MACvB,IAAIA,QAAAA,WAAW,KAAK;AAAA,QAClB,OAAO;AAAA,QACP;AAAA,QACA,QAAQ;AAAA,QACR,GAAG;AAAA,MACJ,CAAA;AAAA,IAAA;AAAA,EAEL;AACF;;;;;;AChBA,MAAM,eAAe,CAAC,oBAA2C,OAAuB;AAChF,QAAA,gBAAgBC,qBAAmC;AAElD,SAAA,OAAO,eAAe,iBAAiB;AAEvC,SAAAC,mBAAQ,aAAa,aAAa;AAC3C;;;;;"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as winston from "winston";
|
|
2
|
+
import { config, format, transports } from "winston";
|
|
3
|
+
const LEVELS = config.npm.levels;
|
|
4
|
+
const LEVEL_LABEL = "silly";
|
|
5
|
+
LEVELS[LEVEL_LABEL];
|
|
6
|
+
const logErrors = format((info) => {
|
|
7
|
+
if (info instanceof Error) {
|
|
8
|
+
return { ...info, message: `${info.message}${info.stack ? `
|
|
9
|
+
${info.stack}` : ""}` };
|
|
10
|
+
}
|
|
11
|
+
return info;
|
|
12
|
+
});
|
|
13
|
+
const defaultTimestampFormat = "YYYY-MM-DD HH:mm:ss.SSS";
|
|
14
|
+
const prettyPrint = (options = {}) => {
|
|
15
|
+
const { timestamps = true, colors = true } = options;
|
|
16
|
+
const handlers = [];
|
|
17
|
+
if (timestamps) {
|
|
18
|
+
handlers.push(
|
|
19
|
+
format.timestamp({
|
|
20
|
+
format: timestamps === true ? defaultTimestampFormat : timestamps
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (colors) {
|
|
25
|
+
handlers.push(format.colorize());
|
|
26
|
+
}
|
|
27
|
+
handlers.push(logErrors());
|
|
28
|
+
handlers.push(
|
|
29
|
+
format.printf(({ level, message, timestamp }) => {
|
|
30
|
+
return `${timestamps ? `[${timestamp}] ` : ""}${level}: ${message}`;
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
return format.combine(...handlers);
|
|
34
|
+
};
|
|
35
|
+
const levelFilter = (...levels) => {
|
|
36
|
+
return format((info) => levels.some((level) => info.level.includes(level)) ? info : false)();
|
|
37
|
+
};
|
|
38
|
+
const excludeColors = format.printf(({ message }) => {
|
|
39
|
+
if (typeof message !== "string") {
|
|
40
|
+
return message;
|
|
41
|
+
}
|
|
42
|
+
return message.replace(
|
|
43
|
+
// eslint-disable-next-line no-control-regex
|
|
44
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
45
|
+
""
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
const detailedLog = format.printf(({ message, level, timestamp }) => {
|
|
49
|
+
if (typeof message !== "string") {
|
|
50
|
+
return message;
|
|
51
|
+
}
|
|
52
|
+
const newMessage = `[${timestamp}] ${level}: ${message}`;
|
|
53
|
+
return newMessage.replace(
|
|
54
|
+
// eslint-disable-next-line no-control-regex
|
|
55
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
56
|
+
""
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
60
|
+
__proto__: null,
|
|
61
|
+
detailedLogs: detailedLog,
|
|
62
|
+
excludeColors,
|
|
63
|
+
levelFilter,
|
|
64
|
+
prettyPrint
|
|
65
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
66
|
+
const defaultConfiguration = () => {
|
|
67
|
+
return {
|
|
68
|
+
level: LEVEL_LABEL,
|
|
69
|
+
levels: LEVELS,
|
|
70
|
+
format: prettyPrint(),
|
|
71
|
+
transports: [new transports.Console()]
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const outputFileConfiguration = (filename, fileTransportOptions = {}) => {
|
|
75
|
+
return {
|
|
76
|
+
level: LEVEL_LABEL,
|
|
77
|
+
levels: LEVELS,
|
|
78
|
+
format: prettyPrint(),
|
|
79
|
+
transports: [
|
|
80
|
+
new transports.Console(),
|
|
81
|
+
new transports.File({
|
|
82
|
+
level: "error",
|
|
83
|
+
filename,
|
|
84
|
+
format: excludeColors,
|
|
85
|
+
...fileTransportOptions
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
91
|
+
__proto__: null,
|
|
92
|
+
createDefaultConfiguration: defaultConfiguration,
|
|
93
|
+
createOutputFileConfiguration: outputFileConfiguration
|
|
94
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
95
|
+
const createLogger = (userConfiguration = {}) => {
|
|
96
|
+
const configuration = defaultConfiguration();
|
|
97
|
+
Object.assign(configuration, userConfiguration);
|
|
98
|
+
return winston.createLogger(configuration);
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
index as configs,
|
|
102
|
+
createLogger,
|
|
103
|
+
index$1 as formats,
|
|
104
|
+
winston
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/constants.ts","../src/formats/log-errors.ts","../src/formats/pretty-print.ts","../src/formats/level-filter.ts","../src/formats/exclude-colors.ts","../src/formats/detailed-log.ts","../src/configs/default-configuration.ts","../src/configs/output-file-configuration.ts","../src/index.ts"],"sourcesContent":["import { config } from 'winston';\n\nconst LEVELS = config.npm.levels;\nconst LEVEL_LABEL = 'silly';\nconst LEVEL = LEVELS[LEVEL_LABEL];\n\nexport { LEVEL, LEVEL_LABEL, LEVELS };\n","import { format, Logform } from 'winston';\n\nconst logErrors: Logform.FormatWrap = format((info) => {\n if (info instanceof Error) {\n return { ...info, message: `${info.message as string}${info.stack ? `\\n${info.stack}` : ''}` };\n }\n\n return info;\n});\n\nexport default logErrors;\n","import { format, Logform } from 'winston';\nimport logErrors from './log-errors';\n\nconst defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';\n\nexport interface PrettyPrintOptions {\n /**\n * Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string\n */\n timestamps?: Logform.TimestampOptions['format'] | boolean;\n /**\n * Enable or disable the use of colors for the log level\n */\n colors?: boolean;\n}\n\n/**\n * Create a pretty print formatter for a winston logger\n * @param options\n */\nexport default (options: PrettyPrintOptions = {}): Logform.Format => {\n const { timestamps = true, colors = true } = options;\n\n const handlers: Logform.Format[] = [];\n\n if (timestamps) {\n handlers.push(\n format.timestamp({\n format: timestamps === true ? defaultTimestampFormat : timestamps,\n })\n );\n }\n\n if (colors) {\n handlers.push(format.colorize());\n }\n\n handlers.push(logErrors());\n\n handlers.push(\n format.printf(({ level, message, timestamp }) => {\n return `${timestamps ? `[${timestamp as string}] ` : ''}${level}: ${message as string}`;\n })\n );\n\n return format.combine(...handlers);\n};\n","import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n return message.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { format } from 'winston';\n\n/**\n * This will remove the chalk color codes from the message provided.\n * It's used to log plain text in the log file\n */\nexport default format.printf(({ message, level, timestamp }) => {\n if (typeof message !== 'string') {\n return message;\n }\n\n const newMessage = `[${timestamp as string}] ${level}: ${message as string}`;\n\n return newMessage.replace(\n // eslint-disable-next-line no-control-regex\n /[\\u001b\\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,\n ''\n );\n});\n","import { transports, LoggerOptions } from 'winston';\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint } from '../formats';\n\nexport default (): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [new transports.Console()],\n };\n};\n","import { transports, LoggerOptions } from 'winston';\n\nimport { LEVEL_LABEL, LEVELS } from '../constants';\nimport { prettyPrint, excludeColors } from '../formats';\n\nexport default (\n filename: string,\n fileTransportOptions: transports.FileTransportOptions = {}\n): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({\n level: 'error',\n filename,\n format: excludeColors,\n ...fileTransportOptions,\n }),\n ],\n };\n};\n","import * as winston from 'winston';\nimport * as configs from './configs';\n\nexport * as formats from './formats';\n\nexport type Logger = winston.Logger;\n\nconst createLogger = (userConfiguration: winston.LoggerOptions = {}): winston.Logger => {\n const configuration = configs.createDefaultConfiguration();\n\n Object.assign(configuration, userConfiguration);\n\n return winston.createLogger(configuration);\n};\n\nexport { createLogger, winston, configs };\n"],"names":["configs.createDefaultConfiguration"],"mappings":";;AAEA,MAAM,SAAS,OAAO,IAAI;AAC1B,MAAM,cAAc;AACN,OAAO,WAAW;ACFhC,MAAM,YAAgC,OAAO,CAAC,SAAS;AACrD,MAAI,gBAAgB,OAAO;AAClB,WAAA,EAAE,GAAG,MAAM,SAAS,GAAG,KAAK,OAAiB,GAAG,KAAK,QAAQ;AAAA,EAAK,KAAK,KAAK,KAAK,EAAE,GAAG;AAAA,EAAA;AAGxF,SAAA;AACT,CAAC;ACLD,MAAM,yBAAyB;AAiB/B,MAAA,cAAe,CAAC,UAA8B,CAAA,MAAuB;AACnE,QAAM,EAAE,aAAa,MAAM,SAAS,KAAS,IAAA;AAE7C,QAAM,WAA6B,CAAC;AAEpC,MAAI,YAAY;AACL,aAAA;AAAA,MACP,OAAO,UAAU;AAAA,QACf,QAAQ,eAAe,OAAO,yBAAyB;AAAA,MACxD,CAAA;AAAA,IACH;AAAA,EAAA;AAGF,MAAI,QAAQ;AACD,aAAA,KAAK,OAAO,UAAU;AAAA,EAAA;AAGxB,WAAA,KAAK,WAAW;AAEhB,WAAA;AAAA,IACP,OAAO,OAAO,CAAC,EAAE,OAAO,SAAS,gBAAgB;AACxC,aAAA,GAAG,aAAa,IAAI,SAAmB,OAAO,EAAE,GAAG,KAAK,KAAK,OAAiB;AAAA,IACtF,CAAA;AAAA,EACH;AAEO,SAAA,OAAO,QAAQ,GAAG,QAAQ;AACnC;AC5CA,MAAe,cAAA,IAAI,WAAqB;AACtC,SAAO,OAAO,CAAC,SAAU,OAAO,KAAK,CAAC,UAAU,KAAK,MAAM,SAAS,KAAK,CAAC,IAAI,OAAO,KAAM,EAAE;AAC/F;ACEA,MAAe,gBAAA,OAAO,OAAO,CAAC,EAAE,cAAc;AACxC,MAAA,OAAO,YAAY,UAAU;AACxB,WAAA;AAAA,EAAA;AAGT,SAAO,QAAQ;AAAA;AAAA,IAEb;AAAA,IACA;AAAA,EACF;AACF,CAAC;ACVD,MAAA,cAAe,OAAO,OAAO,CAAC,EAAE,SAAS,OAAO,gBAAgB;AAC1D,MAAA,OAAO,YAAY,UAAU;AACxB,WAAA;AAAA,EAAA;AAGT,QAAM,aAAa,IAAI,SAAmB,KAAK,KAAK,KAAK,OAAiB;AAE1E,SAAO,WAAW;AAAA;AAAA,IAEhB;AAAA,IACA;AAAA,EACF;AACF,CAAC;;;;;;;;ACdD,MAAA,uBAAe,MAAqB;AAC3B,SAAA;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ,YAAY;AAAA,IACpB,YAAY,CAAC,IAAI,WAAW,QAAS,CAAA;AAAA,EACvC;AACF;ACNA,MAAA,0BAAe,CACb,UACA,uBAAwD,OACtC;AACX,SAAA;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ,YAAY;AAAA,IACpB,YAAY;AAAA,MACV,IAAI,WAAW,QAAQ;AAAA,MACvB,IAAI,WAAW,KAAK;AAAA,QAClB,OAAO;AAAA,QACP;AAAA,QACA,QAAQ;AAAA,QACR,GAAG;AAAA,MACJ,CAAA;AAAA,IAAA;AAAA,EAEL;AACF;;;;;;AChBA,MAAM,eAAe,CAAC,oBAA2C,OAAuB;AAChF,QAAA,gBAAgBA,qBAAmC;AAElD,SAAA,OAAO,eAAe,iBAAiB;AAEvC,SAAA,QAAQ,aAAa,aAAa;AAC3C;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/logger",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.fc1775f7731f8999840e56e298a216b9a6c5c4ad",
|
|
4
4
|
"description": "Strapi's logger",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -24,29 +24,30 @@
|
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
26
|
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.mjs",
|
|
28
|
+
"source": "./src/index.ts",
|
|
27
29
|
"types": "./dist/index.d.ts",
|
|
28
30
|
"files": [
|
|
29
|
-
"
|
|
31
|
+
"dist/"
|
|
30
32
|
],
|
|
31
33
|
"scripts": {
|
|
32
|
-
"build": "
|
|
33
|
-
"build:ts": "run -T tsc",
|
|
34
|
-
"watch": "run -T tsc -w --preserveWatchOutput",
|
|
34
|
+
"build": "pack-up build",
|
|
35
35
|
"clean": "run -T rimraf ./dist",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"lint": "run -T eslint .",
|
|
37
|
+
"test:ts": "run -T tsc --noEmit",
|
|
38
|
+
"watch": "pack-up watch"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"lodash": "4.17.21",
|
|
41
42
|
"winston": "3.10.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"
|
|
45
|
-
"
|
|
45
|
+
"@strapi/pack-up": "5.0.2",
|
|
46
|
+
"eslint-config-custom": "0.0.0-next.fc1775f7731f8999840e56e298a216b9a6c5c4ad",
|
|
47
|
+
"tsconfig": "0.0.0-next.fc1775f7731f8999840e56e298a216b9a6c5c4ad"
|
|
46
48
|
},
|
|
47
49
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
50
|
+
"node": ">=18.0.0 <=22.x.x",
|
|
49
51
|
"npm": ">=6.0.0"
|
|
50
|
-
}
|
|
51
|
-
"gitHead": "fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a"
|
|
52
|
+
}
|
|
52
53
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const winston_1 = require("winston");
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const formats_1 = require("../formats");
|
|
6
|
-
exports.default = () => {
|
|
7
|
-
return {
|
|
8
|
-
level: constants_1.LEVEL_LABEL,
|
|
9
|
-
levels: constants_1.LEVELS,
|
|
10
|
-
format: (0, formats_1.prettyPrint)(),
|
|
11
|
-
transports: [new winston_1.transports.Console()],
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=default-configuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default-configuration.js","sourceRoot":"","sources":["../../src/configs/default-configuration.ts"],"names":[],"mappings":";;AAAA,qCAAoD;AACpD,4CAAmD;AACnD,wCAAyC;AAEzC,kBAAe,GAAkB,EAAE;IACjC,OAAO;QACL,KAAK,EAAE,uBAAW;QAClB,MAAM,EAAE,kBAAM;QACd,MAAM,EAAE,IAAA,qBAAW,GAAE;QACrB,UAAU,EAAE,CAAC,IAAI,oBAAU,CAAC,OAAO,EAAE,CAAC;KACvC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/configs/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createOutputFileConfiguration = exports.createDefaultConfiguration = void 0;
|
|
7
|
-
var default_configuration_1 = require("./default-configuration");
|
|
8
|
-
Object.defineProperty(exports, "createDefaultConfiguration", { enumerable: true, get: function () { return __importDefault(default_configuration_1).default; } });
|
|
9
|
-
var output_file_configuration_1 = require("./output-file-configuration");
|
|
10
|
-
Object.defineProperty(exports, "createOutputFileConfiguration", { enumerable: true, get: function () { return __importDefault(output_file_configuration_1).default; } });
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configs/index.ts"],"names":[],"mappings":";;;;;;AAAA,iEAAgF;AAAvE,oJAAA,OAAO,OAA8B;AAC9C,yEAAuF;AAA9E,2JAAA,OAAO,OAAiC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const winston_1 = require("winston");
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const formats_1 = require("../formats");
|
|
6
|
-
exports.default = (filename) => {
|
|
7
|
-
return {
|
|
8
|
-
level: constants_1.LEVEL_LABEL,
|
|
9
|
-
levels: constants_1.LEVELS,
|
|
10
|
-
format: (0, formats_1.prettyPrint)(),
|
|
11
|
-
transports: [
|
|
12
|
-
new winston_1.transports.Console(),
|
|
13
|
-
new winston_1.transports.File({ level: 'error', filename, format: formats_1.excludeColors }),
|
|
14
|
-
],
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=output-file-configuration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"output-file-configuration.js","sourceRoot":"","sources":["../../src/configs/output-file-configuration.ts"],"names":[],"mappings":";;AAAA,qCAAoD;AAEpD,4CAAmD;AACnD,wCAAwD;AAExD,kBAAe,CAAC,QAAgB,EAAiB,EAAE;IACjD,OAAO;QACL,KAAK,EAAE,uBAAW;QAClB,MAAM,EAAE,kBAAM;QACd,MAAM,EAAE,IAAA,qBAAW,GAAE;QACrB,UAAU,EAAE;YACV,IAAI,oBAAU,CAAC,OAAO,EAAE;YACxB,IAAI,oBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,uBAAa,EAAE,CAAC;SACzE;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/constants.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LEVELS = exports.LEVEL_LABEL = exports.LEVEL = void 0;
|
|
4
|
-
const winston_1 = require("winston");
|
|
5
|
-
const LEVELS = winston_1.config.npm.levels;
|
|
6
|
-
exports.LEVELS = LEVELS;
|
|
7
|
-
const LEVEL_LABEL = 'silly';
|
|
8
|
-
exports.LEVEL_LABEL = LEVEL_LABEL;
|
|
9
|
-
const LEVEL = LEVELS[LEVEL_LABEL];
|
|
10
|
-
exports.LEVEL = LEVEL;
|
|
11
|
-
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAEjC,MAAM,MAAM,GAAG,gBAAM,CAAC,GAAG,CAAC,MAAM,CAAC;AAIJ,wBAAM;AAHnC,MAAM,WAAW,GAAG,OAAO,CAAC;AAGZ,kCAAW;AAF3B,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAEzB,sBAAK"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const winston_1 = require("winston");
|
|
4
|
-
/**
|
|
5
|
-
* This will remove the chalk color codes from the message provided.
|
|
6
|
-
* It's used to log plain text in the log file
|
|
7
|
-
*/
|
|
8
|
-
exports.default = winston_1.format.printf(({ message }) => {
|
|
9
|
-
if (typeof message !== 'string') {
|
|
10
|
-
return message;
|
|
11
|
-
}
|
|
12
|
-
return message.replace(
|
|
13
|
-
// eslint-disable-next-line no-control-regex
|
|
14
|
-
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=exclude-colors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exclude-colors.js","sourceRoot":"","sources":["../../src/formats/exclude-colors.ts"],"names":[],"mappings":";;AAAA,qCAAiC;AAEjC;;;GAGG;AACH,kBAAe,gBAAM,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;IAC3C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,OAAO,CAAC;KAChB;IAED,OAAO,OAAO,CAAC,OAAO;IACpB,4CAA4C;IAC5C,6EAA6E,EAC7E,EAAE,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/formats/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.excludeColors = exports.levelFilter = exports.prettyPrint = void 0;
|
|
7
|
-
var pretty_print_1 = require("./pretty-print");
|
|
8
|
-
Object.defineProperty(exports, "prettyPrint", { enumerable: true, get: function () { return __importDefault(pretty_print_1).default; } });
|
|
9
|
-
var level_filter_1 = require("./level-filter");
|
|
10
|
-
Object.defineProperty(exports, "levelFilter", { enumerable: true, get: function () { return __importDefault(level_filter_1).default; } });
|
|
11
|
-
var exclude_colors_1 = require("./exclude-colors");
|
|
12
|
-
Object.defineProperty(exports, "excludeColors", { enumerable: true, get: function () { return __importDefault(exclude_colors_1).default; } });
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formats/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA4E;AAAnE,4HAAA,OAAO,OAAe;AAC/B,+CAAwD;AAA/C,4HAAA,OAAO,OAAe;AAC/B,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const winston_1 = require("winston");
|
|
4
|
-
exports.default = (...levels) => {
|
|
5
|
-
return (0, winston_1.format)((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=level-filter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"level-filter.js","sourceRoot":"","sources":["../../src/formats/level-filter.ts"],"names":[],"mappings":";;AAAA,qCAAiC;AAEjC,kBAAe,CAAC,GAAG,MAAgB,EAAE,EAAE;IACrC,OAAO,IAAA,gBAAM,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACjG,CAAC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const winston_1 = require("winston");
|
|
4
|
-
const logErrors = (0, winston_1.format)((info) => {
|
|
5
|
-
if (info instanceof Error) {
|
|
6
|
-
return { ...info, message: `${info.message}${info.stack ? `\n${info.stack}` : ''}` };
|
|
7
|
-
}
|
|
8
|
-
return info;
|
|
9
|
-
});
|
|
10
|
-
exports.default = logErrors;
|
|
11
|
-
//# sourceMappingURL=log-errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-errors.js","sourceRoot":"","sources":["../../src/formats/log-errors.ts"],"names":[],"mappings":";;AAAA,qCAA0C;AAE1C,MAAM,SAAS,GAAuB,IAAA,gBAAM,EAAC,CAAC,IAAI,EAAE,EAAE;IACpD,IAAI,IAAI,YAAY,KAAK,EAAE;QACzB,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,OAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;KAChG;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const winston_1 = require("winston");
|
|
7
|
-
const log_errors_1 = __importDefault(require("./log-errors"));
|
|
8
|
-
const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
9
|
-
/**
|
|
10
|
-
* Create a pretty print formatter for a winston logger
|
|
11
|
-
* @param options
|
|
12
|
-
*/
|
|
13
|
-
exports.default = (options = {}) => {
|
|
14
|
-
const { timestamps = true, colors = true } = options;
|
|
15
|
-
const handlers = [];
|
|
16
|
-
if (timestamps) {
|
|
17
|
-
handlers.push(winston_1.format.timestamp({
|
|
18
|
-
format: timestamps === true ? defaultTimestampFormat : timestamps,
|
|
19
|
-
}));
|
|
20
|
-
}
|
|
21
|
-
if (colors) {
|
|
22
|
-
handlers.push(winston_1.format.colorize());
|
|
23
|
-
}
|
|
24
|
-
handlers.push((0, log_errors_1.default)());
|
|
25
|
-
handlers.push(winston_1.format.printf(({ level, message, timestamp }) => {
|
|
26
|
-
return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
|
|
27
|
-
}));
|
|
28
|
-
return winston_1.format.combine(...handlers);
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=pretty-print.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pretty-print.js","sourceRoot":"","sources":["../../src/formats/pretty-print.ts"],"names":[],"mappings":";;;;;AAAA,qCAA0C;AAC1C,8DAAqC;AAErC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAazD;;;GAGG;AACH,kBAAe,CAAC,UAA8B,EAAE,EAAkB,EAAE;IAClE,MAAM,EAAE,UAAU,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,QAAQ,GAAqB,EAAE,CAAC;IAEtC,IAAI,UAAU,EAAE;QACd,QAAQ,CAAC,IAAI,CACX,gBAAM,CAAC,SAAS,CAAC;YACf,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,UAAU;SAClE,CAAC,CACH,CAAC;KACH;IAED,IAAI,MAAM,EAAE;QACV,QAAQ,CAAC,IAAI,CAAC,gBAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;KAClC;IAED,QAAQ,CAAC,IAAI,CAAC,IAAA,oBAAS,GAAE,CAAC,CAAC;IAE3B,QAAQ,CAAC,IAAI,CACX,gBAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;QAC9C,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,SAAmB,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,KAAK,OAAiB,EAAE,CAAC;IAC1F,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,gBAAM,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAC"}
|