@strapi/logger 4.6.0-beta.2 → 4.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{default-configuration.js → configs/default-configuration.js} +2 -2
- package/lib/configs/index.js +9 -0
- package/lib/configs/output-file-configuration.js +20 -0
- package/lib/formats/exclude-colors.js +17 -0
- package/lib/formats/index.js +2 -0
- package/lib/index.js +8 -3
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { transports } = require('winston');
|
|
4
|
-
const { LEVEL_LABEL, LEVELS } = require('
|
|
5
|
-
const { prettyPrint } = require('
|
|
4
|
+
const { LEVEL_LABEL, LEVELS } = require('../constants');
|
|
5
|
+
const { prettyPrint } = require('../formats');
|
|
6
6
|
|
|
7
7
|
const createDefaultConfiguration = () => {
|
|
8
8
|
return {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { transports } = require('winston');
|
|
4
|
+
const { LEVEL_LABEL, LEVELS } = require('../constants');
|
|
5
|
+
const { prettyPrint } = require('../formats');
|
|
6
|
+
const { excludeColors } = require('../formats');
|
|
7
|
+
|
|
8
|
+
const createOutputFileConfiguration = (filename) => {
|
|
9
|
+
return {
|
|
10
|
+
level: LEVEL_LABEL,
|
|
11
|
+
levels: LEVELS,
|
|
12
|
+
format: prettyPrint(),
|
|
13
|
+
transports: [
|
|
14
|
+
new transports.Console(),
|
|
15
|
+
new transports.File({ level: 'error', filename, format: excludeColors }),
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports = createOutputFileConfiguration;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { format } = 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
|
+
*/
|
|
9
|
+
const excludeColors = format.printf(({ message }) => {
|
|
10
|
+
return message.replace(
|
|
11
|
+
// 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
|
+
});
|
|
16
|
+
|
|
17
|
+
module.exports = excludeColors;
|
package/lib/formats/index.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
const winston = require('winston');
|
|
4
4
|
|
|
5
5
|
const formats = require('./formats');
|
|
6
|
-
const
|
|
6
|
+
const configs = require('./configs');
|
|
7
7
|
|
|
8
8
|
const createLogger = (userConfiguration = {}) => {
|
|
9
|
-
const configuration = createDefaultConfiguration();
|
|
9
|
+
const configuration = configs.createDefaultConfiguration();
|
|
10
10
|
|
|
11
11
|
Object.assign(configuration, userConfiguration);
|
|
12
12
|
|
|
13
13
|
return winston.createLogger(configuration);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
module.exports = {
|
|
16
|
+
module.exports = {
|
|
17
|
+
createLogger,
|
|
18
|
+
winston,
|
|
19
|
+
formats,
|
|
20
|
+
configs,
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/logger",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.1",
|
|
4
4
|
"description": "Strapi's logger",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"node": ">=14.19.1 <=18.x.x",
|
|
39
39
|
"npm": ">=6.0.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "17a7845e3d453ea2e7911bda6ec25ed196dd5f16"
|
|
42
42
|
}
|