@strapi/logger 0.0.0-next.f6dca5adf05ef6bed9605a1535999ab0bbbf063e → 0.0.0-next.f86041c89a8c1545c6437a881dc613e98bc52bd7
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/dist/configs/default-configuration.js +21 -0
- package/dist/configs/default-configuration.js.map +1 -0
- package/dist/configs/default-configuration.mjs +19 -0
- package/dist/configs/default-configuration.mjs.map +1 -0
- package/dist/configs/index.js +10 -0
- package/dist/configs/index.js.map +1 -0
- package/dist/configs/index.mjs +3 -0
- package/dist/configs/index.mjs.map +1 -0
- package/dist/configs/output-file-configuration.js +27 -0
- package/dist/configs/output-file-configuration.js.map +1 -0
- package/dist/configs/output-file-configuration.mjs +25 -0
- package/dist/configs/output-file-configuration.mjs.map +1 -0
- package/dist/constants.js +11 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +8 -0
- package/dist/constants.mjs.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/detailed-log.js +18 -0
- package/dist/formats/detailed-log.js.map +1 -0
- package/dist/formats/detailed-log.mjs +16 -0
- package/dist/formats/detailed-log.mjs.map +1 -0
- package/dist/formats/exclude-colors.js +17 -0
- package/dist/formats/exclude-colors.js.map +1 -0
- package/dist/formats/exclude-colors.mjs +15 -0
- package/dist/formats/exclude-colors.mjs.map +1 -0
- package/dist/formats/index.d.ts +1 -0
- package/dist/formats/index.d.ts.map +1 -1
- package/dist/formats/index.js +14 -0
- package/dist/formats/index.js.map +1 -0
- package/dist/formats/index.mjs +5 -0
- package/dist/formats/index.mjs.map +1 -0
- package/dist/formats/level-filter.js +10 -0
- package/dist/formats/level-filter.js.map +1 -0
- package/dist/formats/level-filter.mjs +8 -0
- package/dist/formats/level-filter.mjs.map +1 -0
- package/dist/formats/log-errors.js +16 -0
- package/dist/formats/log-errors.js.map +1 -0
- package/dist/formats/log-errors.mjs +14 -0
- package/dist/formats/log-errors.mjs.map +1 -0
- package/dist/formats/pretty-print.js +29 -0
- package/dist/formats/pretty-print.js.map +1 -0
- package/dist/formats/pretty-print.mjs +27 -0
- package/dist/formats/pretty-print.mjs.map +1 -0
- package/dist/index.js +23 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
var constants = require('../constants.js');
|
|
5
|
+
var prettyPrint = require('../formats/pretty-print.js');
|
|
6
|
+
require('../formats/exclude-colors.js');
|
|
7
|
+
require('../formats/detailed-log.js');
|
|
8
|
+
|
|
9
|
+
var defaultConfiguration = (()=>{
|
|
10
|
+
return {
|
|
11
|
+
level: constants.LEVEL_LABEL,
|
|
12
|
+
levels: constants.LEVELS,
|
|
13
|
+
format: prettyPrint(),
|
|
14
|
+
transports: [
|
|
15
|
+
new winston.transports.Console()
|
|
16
|
+
]
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
module.exports = defaultConfiguration;
|
|
21
|
+
//# sourceMappingURL=default-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-configuration.js","sources":["../../src/configs/default-configuration.ts"],"sourcesContent":["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"],"names":["level","LEVEL_LABEL","levels","LEVELS","format","prettyPrint","transports","Console"],"mappings":";;;;;;;;AAIA,2BAAe,CAAA,IAAA;IACb,OAAO;QACLA,KAAOC,EAAAA,qBAAAA;QACPC,MAAQC,EAAAA,gBAAAA;QACRC,MAAQC,EAAAA,WAAAA,EAAAA;QACRC,UAAY,EAAA;AAAC,YAAA,IAAIA,mBAAWC,OAAO;AAAG;AACxC,KAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { transports } from 'winston';
|
|
2
|
+
import { LEVEL_LABEL, LEVELS } from '../constants.mjs';
|
|
3
|
+
import prettyPrint from '../formats/pretty-print.mjs';
|
|
4
|
+
import '../formats/exclude-colors.mjs';
|
|
5
|
+
import '../formats/detailed-log.mjs';
|
|
6
|
+
|
|
7
|
+
var defaultConfiguration = (()=>{
|
|
8
|
+
return {
|
|
9
|
+
level: LEVEL_LABEL,
|
|
10
|
+
levels: LEVELS,
|
|
11
|
+
format: prettyPrint(),
|
|
12
|
+
transports: [
|
|
13
|
+
new transports.Console()
|
|
14
|
+
]
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export { defaultConfiguration as default };
|
|
19
|
+
//# sourceMappingURL=default-configuration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-configuration.mjs","sources":["../../src/configs/default-configuration.ts"],"sourcesContent":["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"],"names":["level","LEVEL_LABEL","levels","LEVELS","format","prettyPrint","transports","Console"],"mappings":";;;;;;AAIA,2BAAe,CAAA,IAAA;IACb,OAAO;QACLA,KAAOC,EAAAA,WAAAA;QACPC,MAAQC,EAAAA,MAAAA;QACRC,MAAQC,EAAAA,WAAAA,EAAAA;QACRC,UAAY,EAAA;AAAC,YAAA,IAAIA,WAAWC,OAAO;AAAG;AACxC,KAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultConfiguration = require('./default-configuration.js');
|
|
4
|
+
var outputFileConfiguration = require('./output-file-configuration.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.createDefaultConfiguration = defaultConfiguration;
|
|
9
|
+
exports.createOutputFileConfiguration = outputFileConfiguration;
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
var constants = require('../constants.js');
|
|
5
|
+
var prettyPrint = require('../formats/pretty-print.js');
|
|
6
|
+
var excludeColors = require('../formats/exclude-colors.js');
|
|
7
|
+
require('../formats/detailed-log.js');
|
|
8
|
+
|
|
9
|
+
var outputFileConfiguration = ((filename, fileTransportOptions = {})=>{
|
|
10
|
+
return {
|
|
11
|
+
level: constants.LEVEL_LABEL,
|
|
12
|
+
levels: constants.LEVELS,
|
|
13
|
+
format: prettyPrint(),
|
|
14
|
+
transports: [
|
|
15
|
+
new winston.transports.Console(),
|
|
16
|
+
new winston.transports.File({
|
|
17
|
+
level: 'error',
|
|
18
|
+
filename,
|
|
19
|
+
format: excludeColors,
|
|
20
|
+
...fileTransportOptions
|
|
21
|
+
})
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
module.exports = outputFileConfiguration;
|
|
27
|
+
//# sourceMappingURL=output-file-configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-file-configuration.js","sources":["../../src/configs/output-file-configuration.ts"],"sourcesContent":["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"],"names":["filename","fileTransportOptions","level","LEVEL_LABEL","levels","LEVELS","format","prettyPrint","transports","Console","File","excludeColors"],"mappings":";;;;;;;;AAKA,8BAAe,CAAA,CACbA,QACAC,EAAAA,oBAAAA,GAAwD,EAAE,GAAA;IAE1D,OAAO;QACLC,KAAOC,EAAAA,qBAAAA;QACPC,MAAQC,EAAAA,gBAAAA;QACRC,MAAQC,EAAAA,WAAAA,EAAAA;QACRC,UAAY,EAAA;AACV,YAAA,IAAIA,mBAAWC,OAAO,EAAA;YACtB,IAAID,kBAAAA,CAAWE,IAAI,CAAC;gBAClBR,KAAO,EAAA,OAAA;AACPF,gBAAAA,QAAAA;gBACAM,MAAQK,EAAAA,aAAAA;AACR,gBAAA,GAAGV;AACL,aAAA;AACD;AACH,KAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { transports } from 'winston';
|
|
2
|
+
import { LEVEL_LABEL, LEVELS } from '../constants.mjs';
|
|
3
|
+
import prettyPrint from '../formats/pretty-print.mjs';
|
|
4
|
+
import excludeColors from '../formats/exclude-colors.mjs';
|
|
5
|
+
import '../formats/detailed-log.mjs';
|
|
6
|
+
|
|
7
|
+
var outputFileConfiguration = ((filename, fileTransportOptions = {})=>{
|
|
8
|
+
return {
|
|
9
|
+
level: LEVEL_LABEL,
|
|
10
|
+
levels: LEVELS,
|
|
11
|
+
format: prettyPrint(),
|
|
12
|
+
transports: [
|
|
13
|
+
new transports.Console(),
|
|
14
|
+
new transports.File({
|
|
15
|
+
level: 'error',
|
|
16
|
+
filename,
|
|
17
|
+
format: excludeColors,
|
|
18
|
+
...fileTransportOptions
|
|
19
|
+
})
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { outputFileConfiguration as default };
|
|
25
|
+
//# sourceMappingURL=output-file-configuration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-file-configuration.mjs","sources":["../../src/configs/output-file-configuration.ts"],"sourcesContent":["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"],"names":["filename","fileTransportOptions","level","LEVEL_LABEL","levels","LEVELS","format","prettyPrint","transports","Console","File","excludeColors"],"mappings":";;;;;;AAKA,8BAAe,CAAA,CACbA,QACAC,EAAAA,oBAAAA,GAAwD,EAAE,GAAA;IAE1D,OAAO;QACLC,KAAOC,EAAAA,WAAAA;QACPC,MAAQC,EAAAA,MAAAA;QACRC,MAAQC,EAAAA,WAAAA,EAAAA;QACRC,UAAY,EAAA;AACV,YAAA,IAAIA,WAAWC,OAAO,EAAA;YACtB,IAAID,UAAAA,CAAWE,IAAI,CAAC;gBAClBR,KAAO,EAAA,OAAA;AACPF,gBAAAA,QAAAA;gBACAM,MAAQK,EAAAA,aAAAA;AACR,gBAAA,GAAGV;AACL,aAAA;AACD;AACH,KAAA;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
|
|
5
|
+
const LEVELS = winston.config.npm.levels;
|
|
6
|
+
const LEVEL_LABEL = 'silly';
|
|
7
|
+
LEVELS[LEVEL_LABEL];
|
|
8
|
+
|
|
9
|
+
exports.LEVELS = LEVELS;
|
|
10
|
+
exports.LEVEL_LABEL = LEVEL_LABEL;
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.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"],"names":["LEVELS","config","npm","levels","LEVEL_LABEL"],"mappings":";;;;AAEA,MAAMA,MAASC,GAAAA,cAAAA,CAAOC,GAAG,CAACC;AAC1B,MAAMC,WAAc,GAAA;AACNJ,MAAM,CAACI,WAAY;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../src/constants.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"],"names":["LEVELS","config","npm","levels","LEVEL_LABEL"],"mappings":";;AAEA,MAAMA,MAASC,GAAAA,MAAAA,CAAOC,GAAG,CAACC;AAC1B,MAAMC,WAAc,GAAA;AACNJ,MAAM,CAACI,WAAY;;;;"}
|
|
@@ -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,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This will remove the chalk color codes from the message provided.
|
|
7
|
+
* It's used to log plain text in the log file
|
|
8
|
+
*/ var detailedLog = winston.format.printf(({ message, level, timestamp })=>{
|
|
9
|
+
if (typeof message !== 'string') {
|
|
10
|
+
return message;
|
|
11
|
+
}
|
|
12
|
+
const newMessage = `[${timestamp}] ${level}: ${message}`;
|
|
13
|
+
return newMessage.replace(// 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
|
+
|
|
17
|
+
module.exports = detailedLog;
|
|
18
|
+
//# sourceMappingURL=detailed-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detailed-log.js","sources":["../../src/formats/detailed-log.ts"],"sourcesContent":["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"],"names":["format","printf","message","level","timestamp","newMessage","replace"],"mappings":";;;;AAEA;;;IAIA,kBAAeA,cAAOC,CAAAA,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAA;IACzD,IAAI,OAAOF,YAAY,QAAU,EAAA;QAC/B,OAAOA,OAAAA;AACT;IAEA,MAAMG,UAAAA,GAAa,CAAC,CAAC,EAAED,SAAAA,CAAoB,EAAE,EAAED,KAAAA,CAAM,EAAE,EAAED,OAAmB,CAAA,CAAA;IAE5E,OAAOG,UAAAA,CAAWC,OAAO;IAEvB,6EACA,EAAA,EAAA,CAAA;AAEJ,CAAG,CAAA;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { format } from 'winston';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This will remove the chalk color codes from the message provided.
|
|
5
|
+
* It's used to log plain text in the log file
|
|
6
|
+
*/ var detailedLog = format.printf(({ message, level, timestamp })=>{
|
|
7
|
+
if (typeof message !== 'string') {
|
|
8
|
+
return message;
|
|
9
|
+
}
|
|
10
|
+
const newMessage = `[${timestamp}] ${level}: ${message}`;
|
|
11
|
+
return newMessage.replace(// eslint-disable-next-line no-control-regex
|
|
12
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export { detailedLog as default };
|
|
16
|
+
//# sourceMappingURL=detailed-log.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detailed-log.mjs","sources":["../../src/formats/detailed-log.ts"],"sourcesContent":["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"],"names":["format","printf","message","level","timestamp","newMessage","replace"],"mappings":";;AAEA;;;IAIA,kBAAeA,MAAOC,CAAAA,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,GAAA;IACzD,IAAI,OAAOF,YAAY,QAAU,EAAA;QAC/B,OAAOA,OAAAA;AACT;IAEA,MAAMG,UAAAA,GAAa,CAAC,CAAC,EAAED,SAAAA,CAAoB,EAAE,EAAED,KAAAA,CAAM,EAAE,EAAED,OAAmB,CAAA,CAAA;IAE5E,OAAOG,UAAAA,CAAWC,OAAO;IAEvB,6EACA,EAAA,EAAA,CAAA;AAEJ,CAAG,CAAA;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This will remove the chalk color codes from the message provided.
|
|
7
|
+
* It's used to log plain text in the log file
|
|
8
|
+
*/ var excludeColors = winston.format.printf(({ message })=>{
|
|
9
|
+
if (typeof message !== 'string') {
|
|
10
|
+
return message;
|
|
11
|
+
}
|
|
12
|
+
return message.replace(// eslint-disable-next-line no-control-regex
|
|
13
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
module.exports = excludeColors;
|
|
17
|
+
//# sourceMappingURL=exclude-colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclude-colors.js","sources":["../../src/formats/exclude-colors.ts"],"sourcesContent":["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"],"names":["format","printf","message","replace"],"mappings":";;;;AAEA;;;AAGC,IACD,oBAAeA,cAAOC,CAAAA,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAA;IACvC,IAAI,OAAOA,YAAY,QAAU,EAAA;QAC/B,OAAOA,OAAAA;AACT;IAEA,OAAOA,OAAAA,CAAQC,OAAO;IAEpB,6EACA,EAAA,EAAA,CAAA;AAEJ,CAAG,CAAA;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { format } from 'winston';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This will remove the chalk color codes from the message provided.
|
|
5
|
+
* It's used to log plain text in the log file
|
|
6
|
+
*/ var excludeColors = format.printf(({ message })=>{
|
|
7
|
+
if (typeof message !== 'string') {
|
|
8
|
+
return message;
|
|
9
|
+
}
|
|
10
|
+
return message.replace(// eslint-disable-next-line no-control-regex
|
|
11
|
+
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export { excludeColors as default };
|
|
15
|
+
//# sourceMappingURL=exclude-colors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exclude-colors.mjs","sources":["../../src/formats/exclude-colors.ts"],"sourcesContent":["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"],"names":["format","printf","message","replace"],"mappings":";;AAEA;;;AAGC,IACD,oBAAeA,MAAOC,CAAAA,MAAM,CAAC,CAAC,EAAEC,OAAO,EAAE,GAAA;IACvC,IAAI,OAAOA,YAAY,QAAU,EAAA;QAC/B,OAAOA,OAAAA;AACT;IAEA,OAAOA,OAAAA,CAAQC,OAAO;IAEpB,6EACA,EAAA,EAAA,CAAA;AAEJ,CAAG,CAAA;;;;"}
|
package/dist/formats/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { default as prettyPrint } from './pretty-print';
|
|
|
2
2
|
export type { PrettyPrintOptions } from './pretty-print';
|
|
3
3
|
export { default as levelFilter } from './level-filter';
|
|
4
4
|
export { default as excludeColors } from './exclude-colors';
|
|
5
|
+
export { default as detailedLogs } from './detailed-log';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prettyPrint = require('./pretty-print.js');
|
|
4
|
+
var levelFilter = require('./level-filter.js');
|
|
5
|
+
var excludeColors = require('./exclude-colors.js');
|
|
6
|
+
var detailedLog = require('./detailed-log.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.prettyPrint = prettyPrint;
|
|
11
|
+
exports.levelFilter = levelFilter;
|
|
12
|
+
exports.excludeColors = excludeColors;
|
|
13
|
+
exports.detailedLogs = detailedLog;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as prettyPrint } from './pretty-print.mjs';
|
|
2
|
+
export { default as levelFilter } from './level-filter.mjs';
|
|
3
|
+
export { default as excludeColors } from './exclude-colors.mjs';
|
|
4
|
+
export { default as detailedLogs } from './detailed-log.mjs';
|
|
5
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
|
|
5
|
+
var levelFilter = ((...levels)=>{
|
|
6
|
+
return winston.format((info)=>levels.some((level)=>info.level.includes(level)) ? info : false)();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
module.exports = levelFilter;
|
|
10
|
+
//# sourceMappingURL=level-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level-filter.js","sources":["../../src/formats/level-filter.ts"],"sourcesContent":["import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n"],"names":["levels","format","info","some","level","includes"],"mappings":";;;;AAEA,kBAAe,CAAA,CAAC,GAAGA,MAAAA,GAAAA;AACjB,IAAA,OAAOC,cAAO,CAAA,CAACC,IAAUF,GAAAA,MAAAA,CAAOG,IAAI,CAAC,CAACC,KAAUF,GAAAA,IAAAA,CAAKE,KAAK,CAACC,QAAQ,CAACD,UAAUF,IAAO,GAAA,KAAA,CAAA,EAAA;AACvF,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level-filter.mjs","sources":["../../src/formats/level-filter.ts"],"sourcesContent":["import { format } from 'winston';\n\nexport default (...levels: string[]) => {\n return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();\n};\n"],"names":["levels","format","info","some","level","includes"],"mappings":";;AAEA,kBAAe,CAAA,CAAC,GAAGA,MAAAA,GAAAA;AACjB,IAAA,OAAOC,MAAO,CAAA,CAACC,IAAUF,GAAAA,MAAAA,CAAOG,IAAI,CAAC,CAACC,KAAUF,GAAAA,IAAAA,CAAKE,KAAK,CAACC,QAAQ,CAACD,UAAUF,IAAO,GAAA,KAAA,CAAA,EAAA;AACvF,CAAA;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
|
|
5
|
+
const logErrors = winston.format((info)=>{
|
|
6
|
+
if (info instanceof Error) {
|
|
7
|
+
return {
|
|
8
|
+
...info,
|
|
9
|
+
message: `${info.message}${info.stack ? `\n${info.stack}` : ''}`
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return info;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
module.exports = logErrors;
|
|
16
|
+
//# sourceMappingURL=log-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-errors.js","sources":["../../src/formats/log-errors.ts"],"sourcesContent":["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"],"names":["logErrors","format","info","Error","message","stack"],"mappings":";;;;AAEMA,MAAAA,SAAAA,GAAgCC,eAAO,CAACC,IAAAA,GAAAA;AAC5C,IAAA,IAAIA,gBAAgBC,KAAO,EAAA;QACzB,OAAO;AAAE,YAAA,GAAGD,IAAI;AAAEE,YAAAA,OAAAA,EAAS,CAAGF,EAAAA,IAAAA,CAAKE,OAAO,CAAA,EAAaF,KAAKG,KAAK,GAAG,CAAC,EAAE,EAAEH,IAAAA,CAAKG,KAAK,CAAA,CAAE,GAAG,EAAI,CAAA;AAAC,SAAA;AAC/F;IAEA,OAAOH,IAAAA;AACT,CAAA;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { format } from 'winston';
|
|
2
|
+
|
|
3
|
+
const logErrors = format((info)=>{
|
|
4
|
+
if (info instanceof Error) {
|
|
5
|
+
return {
|
|
6
|
+
...info,
|
|
7
|
+
message: `${info.message}${info.stack ? `\n${info.stack}` : ''}`
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
return info;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { logErrors as default };
|
|
14
|
+
//# sourceMappingURL=log-errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-errors.mjs","sources":["../../src/formats/log-errors.ts"],"sourcesContent":["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"],"names":["logErrors","format","info","Error","message","stack"],"mappings":";;AAEMA,MAAAA,SAAAA,GAAgCC,OAAO,CAACC,IAAAA,GAAAA;AAC5C,IAAA,IAAIA,gBAAgBC,KAAO,EAAA;QACzB,OAAO;AAAE,YAAA,GAAGD,IAAI;AAAEE,YAAAA,OAAAA,EAAS,CAAGF,EAAAA,IAAAA,CAAKE,OAAO,CAAA,EAAaF,KAAKG,KAAK,GAAG,CAAC,EAAE,EAAEH,IAAAA,CAAKG,KAAK,CAAA,CAAE,GAAG,EAAI,CAAA;AAAC,SAAA;AAC/F;IAEA,OAAOH,IAAAA;AACT,CAAA;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
var logErrors = require('./log-errors.js');
|
|
5
|
+
|
|
6
|
+
const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
7
|
+
/**
|
|
8
|
+
* Create a pretty print formatter for a winston logger
|
|
9
|
+
* @param options
|
|
10
|
+
*/ var prettyPrint = ((options = {})=>{
|
|
11
|
+
const { timestamps = true, colors = true } = options;
|
|
12
|
+
const handlers = [];
|
|
13
|
+
if (timestamps) {
|
|
14
|
+
handlers.push(winston.format.timestamp({
|
|
15
|
+
format: timestamps === true ? defaultTimestampFormat : timestamps
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
if (colors) {
|
|
19
|
+
handlers.push(winston.format.colorize());
|
|
20
|
+
}
|
|
21
|
+
handlers.push(logErrors());
|
|
22
|
+
handlers.push(winston.format.printf(({ level, message, timestamp })=>{
|
|
23
|
+
return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
|
|
24
|
+
}));
|
|
25
|
+
return winston.format.combine(...handlers);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
module.exports = prettyPrint;
|
|
29
|
+
//# sourceMappingURL=pretty-print.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-print.js","sources":["../../src/formats/pretty-print.ts"],"sourcesContent":["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"],"names":["defaultTimestampFormat","options","timestamps","colors","handlers","push","format","timestamp","colorize","logErrors","printf","level","message","combine"],"mappings":";;;;;AAGA,MAAMA,sBAAyB,GAAA,yBAAA;AAa/B;;;AAGC,IACD,kBAAe,CAAA,CAACC,OAAAA,GAA8B,EAAE,GAAA;AAC9C,IAAA,MAAM,EAAEC,UAAa,GAAA,IAAI,EAAEC,MAAS,GAAA,IAAI,EAAE,GAAGF,OAAAA;AAE7C,IAAA,MAAMG,WAA6B,EAAE;AAErC,IAAA,IAAIF,UAAY,EAAA;AACdE,QAAAA,QAAAA,CAASC,IAAI,CACXC,cAAOC,CAAAA,SAAS,CAAC;YACfD,MAAQJ,EAAAA,UAAAA,KAAe,OAAOF,sBAAyBE,GAAAA;AACzD,SAAA,CAAA,CAAA;AAEJ;AAEA,IAAA,IAAIC,MAAQ,EAAA;QACVC,QAASC,CAAAA,IAAI,CAACC,cAAAA,CAAOE,QAAQ,EAAA,CAAA;AAC/B;AAEAJ,IAAAA,QAAAA,CAASC,IAAI,CAACI,SAAAA,EAAAA,CAAAA;AAEdL,IAAAA,QAAAA,CAASC,IAAI,CACXC,cAAOI,CAAAA,MAAM,CAAC,CAAC,EAAEC,KAAK,EAAEC,OAAO,EAAEL,SAAS,EAAE,GAAA;AAC1C,QAAA,OAAO,CAAGL,EAAAA,UAAAA,GAAa,CAAC,CAAC,EAAEK,SAAAA,CAAoB,EAAE,CAAC,GAAG,EAAA,CAAA,EAAKI,KAAM,CAAA,EAAE,EAAEC,OAAmB,CAAA,CAAA;AACzF,KAAA,CAAA,CAAA;IAGF,OAAON,cAAAA,CAAOO,OAAO,CAAIT,GAAAA,QAAAA,CAAAA;AAC3B,CAAA;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { format } from 'winston';
|
|
2
|
+
import logErrors from './log-errors.mjs';
|
|
3
|
+
|
|
4
|
+
const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
5
|
+
/**
|
|
6
|
+
* Create a pretty print formatter for a winston logger
|
|
7
|
+
* @param options
|
|
8
|
+
*/ var prettyPrint = ((options = {})=>{
|
|
9
|
+
const { timestamps = true, colors = true } = options;
|
|
10
|
+
const handlers = [];
|
|
11
|
+
if (timestamps) {
|
|
12
|
+
handlers.push(format.timestamp({
|
|
13
|
+
format: timestamps === true ? defaultTimestampFormat : timestamps
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
if (colors) {
|
|
17
|
+
handlers.push(format.colorize());
|
|
18
|
+
}
|
|
19
|
+
handlers.push(logErrors());
|
|
20
|
+
handlers.push(format.printf(({ level, message, timestamp })=>{
|
|
21
|
+
return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
|
|
22
|
+
}));
|
|
23
|
+
return format.combine(...handlers);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { prettyPrint as default };
|
|
27
|
+
//# sourceMappingURL=pretty-print.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pretty-print.mjs","sources":["../../src/formats/pretty-print.ts"],"sourcesContent":["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"],"names":["defaultTimestampFormat","options","timestamps","colors","handlers","push","format","timestamp","colorize","logErrors","printf","level","message","combine"],"mappings":";;;AAGA,MAAMA,sBAAyB,GAAA,yBAAA;AAa/B;;;AAGC,IACD,kBAAe,CAAA,CAACC,OAAAA,GAA8B,EAAE,GAAA;AAC9C,IAAA,MAAM,EAAEC,UAAa,GAAA,IAAI,EAAEC,MAAS,GAAA,IAAI,EAAE,GAAGF,OAAAA;AAE7C,IAAA,MAAMG,WAA6B,EAAE;AAErC,IAAA,IAAIF,UAAY,EAAA;AACdE,QAAAA,QAAAA,CAASC,IAAI,CACXC,MAAOC,CAAAA,SAAS,CAAC;YACfD,MAAQJ,EAAAA,UAAAA,KAAe,OAAOF,sBAAyBE,GAAAA;AACzD,SAAA,CAAA,CAAA;AAEJ;AAEA,IAAA,IAAIC,MAAQ,EAAA;QACVC,QAASC,CAAAA,IAAI,CAACC,MAAAA,CAAOE,QAAQ,EAAA,CAAA;AAC/B;AAEAJ,IAAAA,QAAAA,CAASC,IAAI,CAACI,SAAAA,EAAAA,CAAAA;AAEdL,IAAAA,QAAAA,CAASC,IAAI,CACXC,MAAOI,CAAAA,MAAM,CAAC,CAAC,EAAEC,KAAK,EAAEC,OAAO,EAAEL,SAAS,EAAE,GAAA;AAC1C,QAAA,OAAO,CAAGL,EAAAA,UAAAA,GAAa,CAAC,CAAC,EAAEK,SAAAA,CAAoB,EAAE,CAAC,GAAG,EAAA,CAAA,EAAKI,KAAM,CAAA,EAAE,EAAEC,OAAmB,CAAA,CAAA;AACzF,KAAA,CAAA,CAAA;IAGF,OAAON,MAAAA,CAAOO,OAAO,CAAIT,GAAAA,QAAAA,CAAAA;AAC3B,CAAA;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,112 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var winston = require('winston');
|
|
4
|
+
var index = require('./configs/index.js');
|
|
5
|
+
var index$1 = require('./formats/index.js');
|
|
6
|
+
var defaultConfiguration = require('./configs/default-configuration.js');
|
|
7
|
+
|
|
8
|
+
function _interopNamespaceDefault(e) {
|
|
9
|
+
var n = Object.create(null);
|
|
8
10
|
if (e) {
|
|
9
|
-
|
|
10
|
-
if (k !==
|
|
11
|
-
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
14
|
Object.defineProperty(n, k, d.get ? d : {
|
|
13
15
|
enumerable: true,
|
|
14
|
-
get: ()
|
|
16
|
+
get: function () { return e[k]; }
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
|
-
}
|
|
19
|
+
});
|
|
18
20
|
}
|
|
19
21
|
n.default = e;
|
|
20
22
|
return Object.freeze(n);
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
${info.stack}` : ""}` };
|
|
30
|
-
}
|
|
31
|
-
return info;
|
|
32
|
-
});
|
|
33
|
-
const defaultTimestampFormat = "YYYY-MM-DD HH:mm:ss.SSS";
|
|
34
|
-
const prettyPrint = (options = {}) => {
|
|
35
|
-
const { timestamps = true, colors = true } = options;
|
|
36
|
-
const handlers = [];
|
|
37
|
-
if (timestamps) {
|
|
38
|
-
handlers.push(
|
|
39
|
-
winston.format.timestamp({
|
|
40
|
-
format: timestamps === true ? defaultTimestampFormat : timestamps
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
if (colors) {
|
|
45
|
-
handlers.push(winston.format.colorize());
|
|
46
|
-
}
|
|
47
|
-
handlers.push(logErrors());
|
|
48
|
-
handlers.push(
|
|
49
|
-
winston.format.printf(({ level, message, timestamp }) => {
|
|
50
|
-
return `${timestamps ? `[${timestamp}] ` : ""}${level}: ${message}`;
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
return winston.format.combine(...handlers);
|
|
54
|
-
};
|
|
55
|
-
const levelFilter = (...levels) => {
|
|
56
|
-
return winston.format((info) => levels.some((level) => info.level.includes(level)) ? info : false)();
|
|
57
|
-
};
|
|
58
|
-
const excludeColors = winston.format.printf(({ message }) => {
|
|
59
|
-
if (typeof message !== "string") {
|
|
60
|
-
return message;
|
|
61
|
-
}
|
|
62
|
-
return message.replace(
|
|
63
|
-
// eslint-disable-next-line no-control-regex
|
|
64
|
-
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
|
|
65
|
-
""
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
69
|
-
__proto__: null,
|
|
70
|
-
excludeColors,
|
|
71
|
-
levelFilter,
|
|
72
|
-
prettyPrint
|
|
73
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
74
|
-
const defaultConfiguration = () => {
|
|
75
|
-
return {
|
|
76
|
-
level: LEVEL_LABEL,
|
|
77
|
-
levels: LEVELS,
|
|
78
|
-
format: prettyPrint(),
|
|
79
|
-
transports: [new winston.transports.Console()]
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
const outputFileConfiguration = (filename, fileTransportOptions = {}) => {
|
|
83
|
-
return {
|
|
84
|
-
level: LEVEL_LABEL,
|
|
85
|
-
levels: LEVELS,
|
|
86
|
-
format: prettyPrint(),
|
|
87
|
-
transports: [
|
|
88
|
-
new winston.transports.Console(),
|
|
89
|
-
new winston.transports.File({
|
|
90
|
-
level: "error",
|
|
91
|
-
filename,
|
|
92
|
-
format: excludeColors,
|
|
93
|
-
...fileTransportOptions
|
|
94
|
-
})
|
|
95
|
-
]
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
99
|
-
__proto__: null,
|
|
100
|
-
createDefaultConfiguration: defaultConfiguration,
|
|
101
|
-
createOutputFileConfiguration: outputFileConfiguration
|
|
102
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
103
|
-
const createLogger = (userConfiguration = {}) => {
|
|
104
|
-
const configuration = defaultConfiguration();
|
|
105
|
-
Object.assign(configuration, userConfiguration);
|
|
106
|
-
return winston__namespace.createLogger(configuration);
|
|
24
|
+
|
|
25
|
+
var winston__namespace = /*#__PURE__*/_interopNamespaceDefault(winston);
|
|
26
|
+
|
|
27
|
+
const createLogger = (userConfiguration = {})=>{
|
|
28
|
+
const configuration = defaultConfiguration();
|
|
29
|
+
Object.assign(configuration, userConfiguration);
|
|
30
|
+
return winston__namespace.createLogger(configuration);
|
|
107
31
|
};
|
|
32
|
+
|
|
108
33
|
exports.winston = winston__namespace;
|
|
109
34
|
exports.configs = index;
|
|
110
|
-
exports.createLogger = createLogger;
|
|
111
35
|
exports.formats = index$1;
|
|
36
|
+
exports.createLogger = createLogger;
|
|
112
37
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["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":["createLogger","userConfiguration","configuration","configs","Object","assign","winston"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,YAAe,GAAA,CAACC,iBAA2C,GAAA,EAAE,GAAA;IACjE,MAAMC,aAAAA,GAAgBC,oBAAkC,EAAA;IAExDC,MAAOC,CAAAA,MAAM,CAACH,aAAeD,EAAAA,iBAAAA,CAAAA;IAE7B,OAAOK,kBAAAA,CAAQN,YAAY,CAACE,aAAAA,CAAAA;AAC9B;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,94 +1,16 @@
|
|
|
1
|
-
import * as winston from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
49
|
-
__proto__: null,
|
|
50
|
-
excludeColors,
|
|
51
|
-
levelFilter,
|
|
52
|
-
prettyPrint
|
|
53
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
54
|
-
const defaultConfiguration = () => {
|
|
55
|
-
return {
|
|
56
|
-
level: LEVEL_LABEL,
|
|
57
|
-
levels: LEVELS,
|
|
58
|
-
format: prettyPrint(),
|
|
59
|
-
transports: [new transports.Console()]
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
const outputFileConfiguration = (filename, fileTransportOptions = {}) => {
|
|
63
|
-
return {
|
|
64
|
-
level: LEVEL_LABEL,
|
|
65
|
-
levels: LEVELS,
|
|
66
|
-
format: prettyPrint(),
|
|
67
|
-
transports: [
|
|
68
|
-
new transports.Console(),
|
|
69
|
-
new transports.File({
|
|
70
|
-
level: "error",
|
|
71
|
-
filename,
|
|
72
|
-
format: excludeColors,
|
|
73
|
-
...fileTransportOptions
|
|
74
|
-
})
|
|
75
|
-
]
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
79
|
-
__proto__: null,
|
|
80
|
-
createDefaultConfiguration: defaultConfiguration,
|
|
81
|
-
createOutputFileConfiguration: outputFileConfiguration
|
|
82
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
83
|
-
const createLogger = (userConfiguration = {}) => {
|
|
84
|
-
const configuration = defaultConfiguration();
|
|
85
|
-
Object.assign(configuration, userConfiguration);
|
|
86
|
-
return winston.createLogger(configuration);
|
|
87
|
-
};
|
|
88
|
-
export {
|
|
89
|
-
index as configs,
|
|
90
|
-
createLogger,
|
|
91
|
-
index$1 as formats,
|
|
92
|
-
winston
|
|
1
|
+
import * as winston from 'winston';
|
|
2
|
+
export { winston };
|
|
3
|
+
import * as index from './configs/index.mjs';
|
|
4
|
+
export { index as configs };
|
|
5
|
+
import * as index$1 from './formats/index.mjs';
|
|
6
|
+
export { index$1 as formats };
|
|
7
|
+
import defaultConfiguration from './configs/default-configuration.mjs';
|
|
8
|
+
|
|
9
|
+
const createLogger = (userConfiguration = {})=>{
|
|
10
|
+
const configuration = defaultConfiguration();
|
|
11
|
+
Object.assign(configuration, userConfiguration);
|
|
12
|
+
return winston.createLogger(configuration);
|
|
93
13
|
};
|
|
14
|
+
|
|
15
|
+
export { createLogger };
|
|
94
16
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["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":["createLogger","userConfiguration","configuration","configs","Object","assign","winston"],"mappings":";;;;;;;;AAOA,MAAMA,YAAe,GAAA,CAACC,iBAA2C,GAAA,EAAE,GAAA;IACjE,MAAMC,aAAAA,GAAgBC,oBAAkC,EAAA;IAExDC,MAAOC,CAAAA,MAAM,CAACH,aAAeD,EAAAA,iBAAAA,CAAAA;IAE7B,OAAOK,OAAAA,CAAQN,YAAY,CAACE,aAAAA,CAAAA;AAC9B;;;;"}
|
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.f86041c89a8c1545c6437a881dc613e98bc52bd7",
|
|
4
4
|
"description": "Strapi's logger",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -31,24 +31,24 @@
|
|
|
31
31
|
"dist/"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
34
|
+
"build": "run -T npm-run-all clean --parallel build:code build:types",
|
|
35
|
+
"build:code": "run -T rollup -c",
|
|
36
|
+
"build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
35
37
|
"clean": "run -T rimraf ./dist",
|
|
36
38
|
"lint": "run -T eslint .",
|
|
37
39
|
"test:ts": "run -T tsc --noEmit",
|
|
38
|
-
"watch": "
|
|
40
|
+
"watch": "run -T rollup -c -w"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"lodash": "4.17.21",
|
|
42
44
|
"winston": "3.10.0"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"tsconfig": "0.0.0-next.f6dca5adf05ef6bed9605a1535999ab0bbbf063e"
|
|
47
|
+
"eslint-config-custom": "0.0.0-next.f86041c89a8c1545c6437a881dc613e98bc52bd7",
|
|
48
|
+
"tsconfig": "0.0.0-next.f86041c89a8c1545c6437a881dc613e98bc52bd7"
|
|
48
49
|
},
|
|
49
50
|
"engines": {
|
|
50
|
-
"node": ">=
|
|
51
|
+
"node": ">=20.0.0 <=24.x.x",
|
|
51
52
|
"npm": ">=6.0.0"
|
|
52
|
-
}
|
|
53
|
-
"gitHead": "f6dca5adf05ef6bed9605a1535999ab0bbbf063e"
|
|
53
|
+
}
|
|
54
54
|
}
|