@strapi/logger 5.4.1 → 5.5.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/detailed-log.d.ts +7 -0
- package/dist/formats/detailed-log.d.ts.map +1 -0
- package/dist/formats/index.d.ts +1 -0
- package/dist/formats/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detailed-log.d.ts","sourceRoot":"","sources":["../../src/formats/detailed-log.ts"],"names":[],"mappings":"AAEA;;;GAGG;;AACH,wBAYG"}
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const winston = require("winston");
|
|
4
4
|
function _interopNamespace(e) {
|
|
5
|
-
if (e && e.__esModule)
|
|
6
|
-
return e;
|
|
5
|
+
if (e && e.__esModule) return e;
|
|
7
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
7
|
if (e) {
|
|
9
8
|
for (const k in e) {
|
|
@@ -65,8 +64,20 @@ const excludeColors = winston.format.printf(({ message }) => {
|
|
|
65
64
|
""
|
|
66
65
|
);
|
|
67
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
|
+
});
|
|
68
78
|
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
69
79
|
__proto__: null,
|
|
80
|
+
detailedLogs: detailedLog,
|
|
70
81
|
excludeColors,
|
|
71
82
|
levelFilter,
|
|
72
83
|
prettyPrint
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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/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 { 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":"
|
|
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,C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AAQ,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
CHANGED
|
@@ -45,8 +45,20 @@ const excludeColors = format.printf(({ message }) => {
|
|
|
45
45
|
""
|
|
46
46
|
);
|
|
47
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
|
+
});
|
|
48
59
|
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
49
60
|
__proto__: null,
|
|
61
|
+
detailedLogs: detailedLog,
|
|
50
62
|
excludeColors,
|
|
51
63
|
levelFilter,
|
|
52
64
|
prettyPrint
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +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/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 { 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,
|
|
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,MAA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M,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": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Strapi's logger",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"winston": "3.10.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@strapi/pack-up": "5.0.
|
|
46
|
-
"eslint-config-custom": "5.
|
|
47
|
-
"tsconfig": "5.
|
|
45
|
+
"@strapi/pack-up": "5.0.2",
|
|
46
|
+
"eslint-config-custom": "5.5.0",
|
|
47
|
+
"tsconfig": "5.5.0"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=18.0.0 <=22.x.x",
|
|
51
51
|
"npm": ">=6.0.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "7d785703f52464577d077c4618cbe68b44f8a9cd"
|
|
54
54
|
}
|