@strapi/logger 4.10.0-beta.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/formats/exclude-colors.d.ts +1 -2
- package/dist/formats/exclude-colors.js.map +1 -1
- package/dist/formats/pretty-print.d.ts +1 -1
- package/package.json +17 -7
- package/lib/configs/default-configuration.js +0 -16
- package/lib/configs/index.js +0 -9
- package/lib/configs/output-file-configuration.js +0 -20
- package/lib/constants.js +0 -13
- package/lib/formats/exclude-colors.js +0 -17
- package/lib/formats/index.js +0 -11
- package/lib/formats/level-filter.js +0 -7
- package/lib/formats/log-errors.js +0 -11
- package/lib/formats/pretty-print.js +0 -40
- package/lib/index.js +0 -21
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Logform } from 'winston';
|
|
2
|
-
declare const _default: Logform.Format;
|
|
3
1
|
/**
|
|
4
2
|
* This will remove the chalk color codes from the message provided.
|
|
5
3
|
* It's used to log plain text in the log file
|
|
6
4
|
*/
|
|
5
|
+
declare const _default: import("logform").Format;
|
|
7
6
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclude-colors.js","sourceRoot":"","sources":["../../src/formats/exclude-colors.ts"],"names":[],"mappings":";;AAAA,
|
|
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"}
|
|
@@ -9,9 +9,9 @@ export interface PrettyPrintOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
colors?: boolean;
|
|
11
11
|
}
|
|
12
|
-
declare const _default: (options?: PrettyPrintOptions) => Logform.Format;
|
|
13
12
|
/**
|
|
14
13
|
* Create a pretty print formatter for a winston logger
|
|
15
14
|
* @param options
|
|
16
15
|
*/
|
|
16
|
+
declare const _default: (options?: PrettyPrintOptions) => Logform.Format;
|
|
17
17
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/logger",
|
|
3
|
-
"version": "4.10.0
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "Strapi's logger",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -23,20 +23,30 @@
|
|
|
23
23
|
"url": "https://strapi.io"
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
|
-
"main": "./
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"./dist"
|
|
30
|
+
],
|
|
30
31
|
"scripts": {
|
|
31
|
-
"
|
|
32
|
+
"build": "run -T tsc",
|
|
33
|
+
"build:ts": "run -T tsc",
|
|
34
|
+
"watch": "run -T tsc -w --preserveWatchOutput",
|
|
35
|
+
"clean": "run -T rimraf ./dist",
|
|
36
|
+
"prepublishOnly": "yarn clean && yarn build",
|
|
37
|
+
"lint": "run -T eslint ."
|
|
32
38
|
},
|
|
33
39
|
"dependencies": {
|
|
34
40
|
"lodash": "4.17.21",
|
|
35
41
|
"winston": "3.3.3"
|
|
36
42
|
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"eslint-config-custom": "4.10.0",
|
|
45
|
+
"tsconfig": "4.10.0"
|
|
46
|
+
},
|
|
37
47
|
"engines": {
|
|
38
48
|
"node": ">=14.19.1 <=18.x.x",
|
|
39
49
|
"npm": ">=6.0.0"
|
|
40
50
|
},
|
|
41
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "9b5519778faaedfb837879f9c6f7e28fdfd6750d"
|
|
42
52
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { transports } = require('winston');
|
|
4
|
-
const { LEVEL_LABEL, LEVELS } = require('../constants');
|
|
5
|
-
const { prettyPrint } = require('../formats');
|
|
6
|
-
|
|
7
|
-
const createDefaultConfiguration = () => {
|
|
8
|
-
return {
|
|
9
|
-
level: LEVEL_LABEL,
|
|
10
|
-
levels: LEVELS,
|
|
11
|
-
format: prettyPrint(),
|
|
12
|
-
transports: [new transports.Console()],
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = createDefaultConfiguration;
|
package/lib/configs/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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;
|
package/lib/constants.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { format } = require('winston');
|
|
4
|
-
const { isString } = require('lodash/fp');
|
|
5
|
-
const logErrors = require('./log-errors');
|
|
6
|
-
|
|
7
|
-
const { combine, timestamp, colorize, printf } = format;
|
|
8
|
-
|
|
9
|
-
const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create a pretty print formatter for a winston logger
|
|
13
|
-
* @param {string|boolean} timestamps - Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string
|
|
14
|
-
* @param {boolean} colors - Enable or disable the use of colors for the log level
|
|
15
|
-
*/
|
|
16
|
-
module.exports = ({ timestamps = true, colors = true } = {}) => {
|
|
17
|
-
const handlers = [];
|
|
18
|
-
|
|
19
|
-
if (timestamps) {
|
|
20
|
-
handlers.push(
|
|
21
|
-
timestamp({
|
|
22
|
-
format: isString(timestamps) ? timestamps : defaultTimestampFormat,
|
|
23
|
-
})
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (colors) {
|
|
28
|
-
handlers.push(colorize());
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
handlers.push(logErrors());
|
|
32
|
-
|
|
33
|
-
handlers.push(
|
|
34
|
-
printf(({ level, message, timestamp }) => {
|
|
35
|
-
return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return combine(...handlers);
|
|
40
|
-
};
|
package/lib/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const winston = require('winston');
|
|
4
|
-
|
|
5
|
-
const formats = require('./formats');
|
|
6
|
-
const configs = require('./configs');
|
|
7
|
-
|
|
8
|
-
const createLogger = (userConfiguration = {}) => {
|
|
9
|
-
const configuration = configs.createDefaultConfiguration();
|
|
10
|
-
|
|
11
|
-
Object.assign(configuration, userConfiguration);
|
|
12
|
-
|
|
13
|
-
return winston.createLogger(configuration);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
createLogger,
|
|
18
|
-
winston,
|
|
19
|
-
formats,
|
|
20
|
-
configs,
|
|
21
|
-
};
|