@strapi/logger 0.0.0-next.fd9757603c653ca239c45d6e28ab536d2dae0b39 → 0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231

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.
@@ -1,4 +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
4
  //# sourceMappingURL=output-file-configuration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output-file-configuration.d.ts","sourceRoot":"","sources":["../../src/configs/output-file-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,SAAS,CAAC;mCAK1B,MAAM,KAAG,aAAa;AAAhD,wBAUE"}
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"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This will remove the chalk color codes from the message provided.
3
+ * It's used to log plain text in the log file
4
+ */
5
+ declare const _default: import("logform").Format;
6
+ export default _default;
7
+ //# sourceMappingURL=detailed-log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detailed-log.d.ts","sourceRoot":"","sources":["../../src/formats/detailed-log.ts"],"names":[],"mappings":"AAEA;;;GAGG;;AACH,wBAYG"}
@@ -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
@@ -1,105 +1,137 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const winston = require("winston");
4
- function _interopNamespace(e) {
5
- if (e && e.__esModule)
6
- return e;
7
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
1
+ 'use strict';
2
+
3
+ var winston = require('winston');
4
+
5
+ function _interopNamespaceDefault(e) {
6
+ var n = Object.create(null);
8
7
  if (e) {
9
- for (const k in e) {
10
- if (k !== "default") {
11
- const d = Object.getOwnPropertyDescriptor(e, k);
8
+ Object.keys(e).forEach(function (k) {
9
+ if (k !== 'default') {
10
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
11
  Object.defineProperty(n, k, d.get ? d : {
13
12
  enumerable: true,
14
- get: () => e[k]
13
+ get: function () { return e[k]; }
15
14
  });
16
15
  }
17
- }
16
+ });
18
17
  }
19
18
  n.default = e;
20
19
  return Object.freeze(n);
21
20
  }
22
- const winston__namespace = /* @__PURE__ */ _interopNamespace(winston);
21
+
22
+ var winston__namespace = /*#__PURE__*/_interopNamespaceDefault(winston);
23
+
23
24
  const LEVELS = winston.config.npm.levels;
24
- const LEVEL_LABEL = "silly";
25
+ const LEVEL_LABEL = 'silly';
25
26
  LEVELS[LEVEL_LABEL];
26
- const logErrors = winston.format((info) => {
27
- if (info instanceof Error) {
28
- return { ...info, message: `${info.message}${info.stack ? `
29
- ${info.stack}` : ""}` };
30
- }
31
- return info;
27
+
28
+ const logErrors = winston.format((info)=>{
29
+ if (info instanceof Error) {
30
+ return {
31
+ ...info,
32
+ message: `${info.message}${info.stack ? `\n${info.stack}` : ''}`
33
+ };
34
+ }
35
+ return info;
32
36
  });
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
- );
37
+
38
+ const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
39
+ /**
40
+ * Create a pretty print formatter for a winston logger
41
+ * @param options
42
+ */ var prettyPrint = ((options = {})=>{
43
+ const { timestamps = true, colors = true } = options;
44
+ const handlers = [];
45
+ if (timestamps) {
46
+ handlers.push(winston.format.timestamp({
47
+ format: timestamps === true ? defaultTimestampFormat : timestamps
48
+ }));
49
+ }
50
+ if (colors) {
51
+ handlers.push(winston.format.colorize());
52
+ }
53
+ handlers.push(logErrors());
54
+ handlers.push(winston.format.printf(({ level, message, timestamp })=>{
55
+ return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
56
+ }));
57
+ return winston.format.combine(...handlers);
58
+ });
59
+
60
+ var levelFilter = ((...levels)=>{
61
+ return winston.format((info)=>levels.some((level)=>info.level.includes(level)) ? info : false)();
67
62
  });
68
- const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
63
+
64
+ /**
65
+ * This will remove the chalk color codes from the message provided.
66
+ * It's used to log plain text in the log file
67
+ */ var excludeColors = winston.format.printf(({ message })=>{
68
+ if (typeof message !== 'string') {
69
+ return message;
70
+ }
71
+ return message.replace(// eslint-disable-next-line no-control-regex
72
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
73
+ });
74
+
75
+ /**
76
+ * This will remove the chalk color codes from the message provided.
77
+ * It's used to log plain text in the log file
78
+ */ var detailedLog = winston.format.printf(({ message, level, timestamp })=>{
79
+ if (typeof message !== 'string') {
80
+ return message;
81
+ }
82
+ const newMessage = `[${timestamp}] ${level}: ${message}`;
83
+ return newMessage.replace(// eslint-disable-next-line no-control-regex
84
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
85
+ });
86
+
87
+ var index$1 = /*#__PURE__*/Object.freeze({
69
88
  __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) => {
83
- return {
84
- level: LEVEL_LABEL,
85
- levels: LEVELS,
86
- format: prettyPrint(),
87
- transports: [
88
- new winston.transports.Console(),
89
- new winston.transports.File({ level: "error", filename, format: excludeColors })
90
- ]
91
- };
92
- };
93
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
89
+ detailedLogs: detailedLog,
90
+ excludeColors: excludeColors,
91
+ levelFilter: levelFilter,
92
+ prettyPrint: prettyPrint
93
+ });
94
+
95
+ var defaultConfiguration = (()=>{
96
+ return {
97
+ level: LEVEL_LABEL,
98
+ levels: LEVELS,
99
+ format: prettyPrint(),
100
+ transports: [
101
+ new winston.transports.Console()
102
+ ]
103
+ };
104
+ });
105
+
106
+ var outputFileConfiguration = ((filename, fileTransportOptions = {})=>{
107
+ return {
108
+ level: LEVEL_LABEL,
109
+ levels: LEVELS,
110
+ format: prettyPrint(),
111
+ transports: [
112
+ new winston.transports.Console(),
113
+ new winston.transports.File({
114
+ level: 'error',
115
+ filename,
116
+ format: excludeColors,
117
+ ...fileTransportOptions
118
+ })
119
+ ]
120
+ };
121
+ });
122
+
123
+ var index = /*#__PURE__*/Object.freeze({
94
124
  __proto__: null,
95
125
  createDefaultConfiguration: defaultConfiguration,
96
126
  createOutputFileConfiguration: outputFileConfiguration
97
- }, Symbol.toStringTag, { value: "Module" }));
98
- const createLogger = (userConfiguration = {}) => {
99
- const configuration = defaultConfiguration();
100
- Object.assign(configuration, userConfiguration);
101
- return winston__namespace.createLogger(configuration);
127
+ });
128
+
129
+ const createLogger = (userConfiguration = {})=>{
130
+ const configuration = defaultConfiguration();
131
+ Object.assign(configuration, userConfiguration);
132
+ return winston__namespace.createLogger(configuration);
102
133
  };
134
+
103
135
  exports.winston = winston__namespace;
104
136
  exports.configs = index;
105
137
  exports.createLogger = createLogger;
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 (filename: string): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({ level: 'error', filename, format: excludeColors }),\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,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;AAAA,IACR,QAAQ,YAAY;AAAA,IACpB,YAAY;AAAA,MACV,IAAIA,QAAAA,WAAW,QAAQ;AAAA,MACvB,IAAIA,mBAAW,KAAK,EAAE,OAAO,SAAS,UAAU,QAAQ,eAAe;AAAA,IACzE;AAAA,EAAA;AAEJ;;;;;;ACRA,MAAM,eAAe,CAAC,oBAA2C,OAAuB;AAChF,QAAA,gBAAgBC;AAEf,SAAA,OAAO,eAAe,iBAAiB;AAEvC,SAAAC,mBAAQ,aAAa,aAAa;AAC3C;;;;;"}
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":["LEVELS","config","npm","levels","LEVEL_LABEL","logErrors","format","info","Error","message","stack","defaultTimestampFormat","options","timestamps","colors","handlers","push","timestamp","colorize","printf","level","combine","some","includes","replace","newMessage","prettyPrint","transports","Console","filename","fileTransportOptions","File","excludeColors","createLogger","userConfiguration","configuration","configs","Object","assign","winston"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA,MAASC,GAAAA,cAAAA,CAAOC,GAAG,CAACC,MAAM;AAChC,MAAMC,WAAc,GAAA,OAAA;AACNJ,MAAM,CAACI,WAAY;;ACFjC,MAAMC,SAAAA,GAAgCC,eAAO,CAACC,IAAAA,GAAAA;AAC5C,IAAA,IAAIA,gBAAgBC,KAAO,EAAA;QACzB,OAAO;AAAE,YAAA,GAAGD,IAAI;AAAEE,YAAAA,OAAAA,EAAS,CAAC,EAAEF,IAAAA,CAAKE,OAAO,CAAW,EAAEF,KAAKG,KAAK,GAAG,CAAC,EAAE,EAAEH,IAAKG,CAAAA,KAAK,CAAC,CAAC,GAAG,GAAG;AAAE,SAAA;AAC/F;IAEA,OAAOH,IAAAA;AACT,CAAA,CAAA;;ACLA,MAAMI,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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117 @@
1
- import * as winston from "winston";
2
- import { config, format, transports } from "winston";
1
+ import * as winston from 'winston';
2
+ import { config, format, transports } from 'winston';
3
+ export { winston };
4
+
3
5
  const LEVELS = config.npm.levels;
4
- const LEVEL_LABEL = "silly";
6
+ const LEVEL_LABEL = 'silly';
5
7
  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;
8
+
9
+ const logErrors = format((info)=>{
10
+ if (info instanceof Error) {
11
+ return {
12
+ ...info,
13
+ message: `${info.message}${info.stack ? `\n${info.stack}` : ''}`
14
+ };
15
+ }
16
+ return info;
12
17
  });
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
- );
18
+
19
+ const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
20
+ /**
21
+ * Create a pretty print formatter for a winston logger
22
+ * @param options
23
+ */ var prettyPrint = ((options = {})=>{
24
+ const { timestamps = true, colors = true } = options;
25
+ const handlers = [];
26
+ if (timestamps) {
27
+ handlers.push(format.timestamp({
28
+ format: timestamps === true ? defaultTimestampFormat : timestamps
29
+ }));
30
+ }
31
+ if (colors) {
32
+ handlers.push(format.colorize());
33
+ }
34
+ handlers.push(logErrors());
35
+ handlers.push(format.printf(({ level, message, timestamp })=>{
36
+ return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
37
+ }));
38
+ return format.combine(...handlers);
39
+ });
40
+
41
+ var levelFilter = ((...levels)=>{
42
+ return format((info)=>levels.some((level)=>info.level.includes(level)) ? info : false)();
47
43
  });
48
- const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
44
+
45
+ /**
46
+ * This will remove the chalk color codes from the message provided.
47
+ * It's used to log plain text in the log file
48
+ */ var excludeColors = format.printf(({ message })=>{
49
+ if (typeof message !== 'string') {
50
+ return message;
51
+ }
52
+ return message.replace(// eslint-disable-next-line no-control-regex
53
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
54
+ });
55
+
56
+ /**
57
+ * This will remove the chalk color codes from the message provided.
58
+ * It's used to log plain text in the log file
59
+ */ var detailedLog = format.printf(({ message, level, timestamp })=>{
60
+ if (typeof message !== 'string') {
61
+ return message;
62
+ }
63
+ const newMessage = `[${timestamp}] ${level}: ${message}`;
64
+ return newMessage.replace(// eslint-disable-next-line no-control-regex
65
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
66
+ });
67
+
68
+ var index$1 = /*#__PURE__*/Object.freeze({
49
69
  __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) => {
63
- return {
64
- level: LEVEL_LABEL,
65
- levels: LEVELS,
66
- format: prettyPrint(),
67
- transports: [
68
- new transports.Console(),
69
- new transports.File({ level: "error", filename, format: excludeColors })
70
- ]
71
- };
72
- };
73
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
70
+ detailedLogs: detailedLog,
71
+ excludeColors: excludeColors,
72
+ levelFilter: levelFilter,
73
+ prettyPrint: prettyPrint
74
+ });
75
+
76
+ var defaultConfiguration = (()=>{
77
+ return {
78
+ level: LEVEL_LABEL,
79
+ levels: LEVELS,
80
+ format: prettyPrint(),
81
+ transports: [
82
+ new transports.Console()
83
+ ]
84
+ };
85
+ });
86
+
87
+ var outputFileConfiguration = ((filename, fileTransportOptions = {})=>{
88
+ return {
89
+ level: LEVEL_LABEL,
90
+ levels: LEVELS,
91
+ format: prettyPrint(),
92
+ transports: [
93
+ new transports.Console(),
94
+ new transports.File({
95
+ level: 'error',
96
+ filename,
97
+ format: excludeColors,
98
+ ...fileTransportOptions
99
+ })
100
+ ]
101
+ };
102
+ });
103
+
104
+ var index = /*#__PURE__*/Object.freeze({
74
105
  __proto__: null,
75
106
  createDefaultConfiguration: defaultConfiguration,
76
107
  createOutputFileConfiguration: outputFileConfiguration
77
- }, Symbol.toStringTag, { value: "Module" }));
78
- const createLogger = (userConfiguration = {}) => {
79
- const configuration = defaultConfiguration();
80
- Object.assign(configuration, userConfiguration);
81
- return winston.createLogger(configuration);
82
- };
83
- export {
84
- index as configs,
85
- createLogger,
86
- index$1 as formats,
87
- winston
108
+ });
109
+
110
+ const createLogger = (userConfiguration = {})=>{
111
+ const configuration = defaultConfiguration();
112
+ Object.assign(configuration, userConfiguration);
113
+ return winston.createLogger(configuration);
88
114
  };
115
+
116
+ export { index as configs, createLogger, index$1 as formats };
89
117
  //# sourceMappingURL=index.mjs.map
@@ -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 (filename: string): LoggerOptions => {\n return {\n level: LEVEL_LABEL,\n levels: LEVELS,\n format: prettyPrint(),\n transports: [\n new transports.Console(),\n new transports.File({ level: 'error', filename, format: excludeColors }),\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,EAC/F;AAEO,SAAA;AACT,CAAC;ACLD,MAAM,yBAAyB;AAiB/B,MAAA,cAAe,CAAC,UAA8B,CAAA,MAAuB;AACnE,QAAM,EAAE,aAAa,MAAM,SAAS,SAAS;AAE7C,QAAM,WAA6B,CAAA;AA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QAAA,gBAAgBA;AAEf,SAAA,OAAO,eAAe,iBAAiB;AAEvC,SAAA,QAAQ,aAAa,aAAa;AAC3C;"}
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":["LEVELS","config","npm","levels","LEVEL_LABEL","logErrors","format","info","Error","message","stack","defaultTimestampFormat","options","timestamps","colors","handlers","push","timestamp","colorize","printf","level","combine","some","includes","replace","newMessage","prettyPrint","transports","Console","filename","fileTransportOptions","File","excludeColors","createLogger","userConfiguration","configuration","configs","Object","assign","winston"],"mappings":";;;;AAEA,MAAMA,MAASC,GAAAA,MAAAA,CAAOC,GAAG,CAACC,MAAM;AAChC,MAAMC,WAAc,GAAA,OAAA;AACNJ,MAAM,CAACI,WAAY;;ACFjC,MAAMC,SAAAA,GAAgCC,OAAO,CAACC,IAAAA,GAAAA;AAC5C,IAAA,IAAIA,gBAAgBC,KAAO,EAAA;QACzB,OAAO;AAAE,YAAA,GAAGD,IAAI;AAAEE,YAAAA,OAAAA,EAAS,CAAC,EAAEF,IAAAA,CAAKE,OAAO,CAAW,EAAEF,KAAKG,KAAK,GAAG,CAAC,EAAE,EAAEH,IAAKG,CAAAA,KAAK,CAAC,CAAC,GAAG,GAAG;AAAE,SAAA;AAC/F;IAEA,OAAOH,IAAAA;AACT,CAAA,CAAA;;ACLA,MAAMI,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,CACXV,MAAOW,CAAAA,SAAS,CAAC;YACfX,MAAQO,EAAAA,UAAAA,KAAe,OAAOF,sBAAyBE,GAAAA;AACzD,SAAA,CAAA,CAAA;AAEJ;AAEA,IAAA,IAAIC,MAAQ,EAAA;QACVC,QAASC,CAAAA,IAAI,CAACV,MAAAA,CAAOY,QAAQ,EAAA,CAAA;AAC/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WD,OAAO;IAEvB,6EACA,EAAA,EAAA,CAAA;AAEJ,CAAG,CAAA;;;;;;;;;;ACdH,2BAAe,CAAA,IAAA;IACb,OAAO;QACLJ,KAAOhB,EAAAA,WAAAA;QACPD,MAAQH,EAAAA,MAAAA;QACRM,MAAQoB,EAAAA,WAAAA,EAAAA;QACRC,UAAY,EAAA;AAAC,YAAA,IAAIA,WAAWC,OAAO;AAAG;AACxC,KAAA;AACF,CAAA;;ACNA,8BAAe,CAAA,CACbC,QACAC,EAAAA,oBAAAA,GAAwD,EAAE,GAAA;IAE1D,OAAO;QACLV,KAAOhB,EAAAA,WAAAA;QACPD,MAAQH,EAAAA,MAAAA;QACRM,MAAQoB,EAAAA,WAAAA,EAAAA;QACRC,UAAY,EAAA;AACV,YAAA,IAAIA,WAAWC,OAAO,EAAA;YACtB,IAAID,UAAAA,CAAWI,IAAI,CAAC;gBAClBX,KAAO,EAAA,OAAA;AACPS,gBAAAA,QAAAA;gBACAvB,MAAQ0B,EAAAA,aAAAA;AACR,gBAAA,GAAGF;AACL,aAAA;AACD;AACH,KAAA;AACF,CAAA;;;;;;;;AChBA,MAAMG,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.fd9757603c653ca239c45d6e28ab536d2dae0b39",
3
+ "version": "0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231",
4
4
  "description": "Strapi's logger",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -28,27 +28,27 @@
28
28
  "source": "./src/index.ts",
29
29
  "types": "./dist/index.d.ts",
30
30
  "files": [
31
- "./dist"
31
+ "dist/"
32
32
  ],
33
33
  "scripts": {
34
- "build": "pack-up 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": "pack-up 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
- "@strapi/pack-up": "4.23.0",
46
- "eslint-config-custom": "0.0.0-next.fd9757603c653ca239c45d6e28ab536d2dae0b39",
47
- "tsconfig": "0.0.0-next.fd9757603c653ca239c45d6e28ab536d2dae0b39"
47
+ "eslint-config-custom": "0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231",
48
+ "tsconfig": "0.0.0-next.fdac61dd05ca665168f51f655f1d165b55ec4231"
48
49
  },
49
50
  "engines": {
50
- "node": ">=18.0.0 <=20.x.x",
51
+ "node": ">=18.0.0 <=22.x.x",
51
52
  "npm": ">=6.0.0"
52
- },
53
- "gitHead": "fd9757603c653ca239c45d6e28ab536d2dae0b39"
53
+ }
54
54
  }