@strapi/logger 4.9.0-exp.90df253ba90fd6879eb56a720a1f80d04ff745b8 → 4.9.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.
Files changed (41) hide show
  1. package/dist/configs/default-configuration.d.ts +3 -0
  2. package/dist/configs/default-configuration.js +14 -0
  3. package/dist/configs/default-configuration.js.map +1 -0
  4. package/dist/configs/index.d.ts +2 -0
  5. package/dist/configs/index.js +11 -0
  6. package/dist/configs/index.js.map +1 -0
  7. package/dist/configs/output-file-configuration.d.ts +3 -0
  8. package/dist/configs/output-file-configuration.js +17 -0
  9. package/dist/configs/output-file-configuration.js.map +1 -0
  10. package/dist/constants.d.ts +5 -0
  11. package/dist/constants.js +11 -0
  12. package/dist/constants.js.map +1 -0
  13. package/dist/formats/exclude-colors.d.ts +6 -0
  14. package/dist/formats/exclude-colors.js +16 -0
  15. package/dist/formats/exclude-colors.js.map +1 -0
  16. package/dist/formats/index.d.ts +3 -0
  17. package/dist/formats/index.js +13 -0
  18. package/dist/formats/index.js.map +1 -0
  19. package/dist/formats/level-filter.d.ts +2 -0
  20. package/dist/formats/level-filter.js +7 -0
  21. package/dist/formats/level-filter.js.map +1 -0
  22. package/dist/formats/log-errors.d.ts +3 -0
  23. package/dist/formats/log-errors.js +11 -0
  24. package/dist/formats/log-errors.js.map +1 -0
  25. package/dist/formats/pretty-print.d.ts +17 -0
  26. package/dist/formats/pretty-print.js +30 -0
  27. package/dist/formats/pretty-print.js.map +1 -0
  28. package/dist/index.d.ts +5 -0
  29. package/dist/index.js +38 -0
  30. package/dist/index.js.map +1 -0
  31. package/package.json +17 -7
  32. package/lib/configs/default-configuration.js +0 -16
  33. package/lib/configs/index.js +0 -9
  34. package/lib/configs/output-file-configuration.js +0 -20
  35. package/lib/constants.js +0 -13
  36. package/lib/formats/exclude-colors.js +0 -17
  37. package/lib/formats/index.js +0 -11
  38. package/lib/formats/level-filter.js +0 -7
  39. package/lib/formats/log-errors.js +0 -11
  40. package/lib/formats/pretty-print.js +0 -40
  41. package/lib/index.js +0 -21
@@ -0,0 +1,3 @@
1
+ import { LoggerOptions } from 'winston';
2
+ declare const _default: () => LoggerOptions;
3
+ export default _default;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const winston_1 = require("winston");
4
+ const constants_1 = require("../constants");
5
+ const formats_1 = require("../formats");
6
+ exports.default = () => {
7
+ return {
8
+ level: constants_1.LEVEL_LABEL,
9
+ levels: constants_1.LEVELS,
10
+ format: (0, formats_1.prettyPrint)(),
11
+ transports: [new winston_1.transports.Console()],
12
+ };
13
+ };
14
+ //# sourceMappingURL=default-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-configuration.js","sourceRoot":"","sources":["../../src/configs/default-configuration.ts"],"names":[],"mappings":";;AAAA,qCAAoD;AACpD,4CAAmD;AACnD,wCAAyC;AAEzC,kBAAe,GAAkB,EAAE;IACjC,OAAO;QACL,KAAK,EAAE,uBAAW;QAClB,MAAM,EAAE,kBAAM;QACd,MAAM,EAAE,IAAA,qBAAW,GAAE;QACrB,UAAU,EAAE,CAAC,IAAI,oBAAU,CAAC,OAAO,EAAE,CAAC;KACvC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as createDefaultConfiguration } from './default-configuration';
2
+ export { default as createOutputFileConfiguration } from './output-file-configuration';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createOutputFileConfiguration = exports.createDefaultConfiguration = void 0;
7
+ var default_configuration_1 = require("./default-configuration");
8
+ Object.defineProperty(exports, "createDefaultConfiguration", { enumerable: true, get: function () { return __importDefault(default_configuration_1).default; } });
9
+ var output_file_configuration_1 = require("./output-file-configuration");
10
+ Object.defineProperty(exports, "createOutputFileConfiguration", { enumerable: true, get: function () { return __importDefault(output_file_configuration_1).default; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configs/index.ts"],"names":[],"mappings":";;;;;;AAAA,iEAAgF;AAAvE,oJAAA,OAAO,OAA8B;AAC9C,yEAAuF;AAA9E,2JAAA,OAAO,OAAiC"}
@@ -0,0 +1,3 @@
1
+ import { LoggerOptions } from 'winston';
2
+ declare const _default: (filename: string) => LoggerOptions;
3
+ export default _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const winston_1 = require("winston");
4
+ const constants_1 = require("../constants");
5
+ const formats_1 = require("../formats");
6
+ exports.default = (filename) => {
7
+ return {
8
+ level: constants_1.LEVEL_LABEL,
9
+ levels: constants_1.LEVELS,
10
+ format: (0, formats_1.prettyPrint)(),
11
+ transports: [
12
+ new winston_1.transports.Console(),
13
+ new winston_1.transports.File({ level: 'error', filename, format: formats_1.excludeColors }),
14
+ ],
15
+ };
16
+ };
17
+ //# sourceMappingURL=output-file-configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-file-configuration.js","sourceRoot":"","sources":["../../src/configs/output-file-configuration.ts"],"names":[],"mappings":";;AAAA,qCAAoD;AAEpD,4CAAmD;AACnD,wCAAwD;AAExD,kBAAe,CAAC,QAAgB,EAAiB,EAAE;IACjD,OAAO;QACL,KAAK,EAAE,uBAAW;QAClB,MAAM,EAAE,kBAAM;QACd,MAAM,EAAE,IAAA,qBAAW,GAAE;QACrB,UAAU,EAAE;YACV,IAAI,oBAAU,CAAC,OAAO,EAAE;YACxB,IAAI,oBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,uBAAa,EAAE,CAAC;SACzE;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { config } from 'winston';
2
+ declare const LEVELS: config.NpmConfigSetLevels;
3
+ declare const LEVEL_LABEL = "silly";
4
+ declare const LEVEL: number;
5
+ export { LEVEL, LEVEL_LABEL, LEVELS };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LEVELS = exports.LEVEL_LABEL = exports.LEVEL = void 0;
4
+ const winston_1 = require("winston");
5
+ const LEVELS = winston_1.config.npm.levels;
6
+ exports.LEVELS = LEVELS;
7
+ const LEVEL_LABEL = 'silly';
8
+ exports.LEVEL_LABEL = LEVEL_LABEL;
9
+ const LEVEL = LEVELS[LEVEL_LABEL];
10
+ exports.LEVEL = LEVEL;
11
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAEjC,MAAM,MAAM,GAAG,gBAAM,CAAC,GAAG,CAAC,MAAM,CAAC;AAIJ,wBAAM;AAHnC,MAAM,WAAW,GAAG,OAAO,CAAC;AAGZ,kCAAW;AAF3B,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAEzB,sBAAK"}
@@ -0,0 +1,6 @@
1
+ declare const _default: import("logform").Format;
2
+ /**
3
+ * This will remove the chalk color codes from the message provided.
4
+ * It's used to log plain text in the log file
5
+ */
6
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const winston_1 = require("winston");
4
+ /**
5
+ * This will remove the chalk color codes from the message provided.
6
+ * It's used to log plain text in the log file
7
+ */
8
+ exports.default = winston_1.format.printf(({ message }) => {
9
+ if (typeof message !== 'string') {
10
+ return message;
11
+ }
12
+ return message.replace(
13
+ // 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
+ //# sourceMappingURL=exclude-colors.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
1
+ export { default as prettyPrint, PrettyPrintOptions } from './pretty-print';
2
+ export { default as levelFilter } from './level-filter';
3
+ export { default as excludeColors } from './exclude-colors';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.excludeColors = exports.levelFilter = exports.prettyPrint = void 0;
7
+ var pretty_print_1 = require("./pretty-print");
8
+ Object.defineProperty(exports, "prettyPrint", { enumerable: true, get: function () { return __importDefault(pretty_print_1).default; } });
9
+ var level_filter_1 = require("./level-filter");
10
+ Object.defineProperty(exports, "levelFilter", { enumerable: true, get: function () { return __importDefault(level_filter_1).default; } });
11
+ var exclude_colors_1 = require("./exclude-colors");
12
+ Object.defineProperty(exports, "excludeColors", { enumerable: true, get: function () { return __importDefault(exclude_colors_1).default; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formats/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA4E;AAAnE,4HAAA,OAAO,OAAe;AAC/B,+CAAwD;AAA/C,4HAAA,OAAO,OAAe;AAC/B,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB"}
@@ -0,0 +1,2 @@
1
+ declare const _default: (...levels: string[]) => import("logform").Format;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const winston_1 = require("winston");
4
+ exports.default = (...levels) => {
5
+ return (0, winston_1.format)((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();
6
+ };
7
+ //# sourceMappingURL=level-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"level-filter.js","sourceRoot":"","sources":["../../src/formats/level-filter.ts"],"names":[],"mappings":";;AAAA,qCAAiC;AAEjC,kBAAe,CAAC,GAAG,MAAgB,EAAE,EAAE;IACrC,OAAO,IAAA,gBAAM,EAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACjG,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Logform } from 'winston';
2
+ declare const logErrors: Logform.FormatWrap;
3
+ export default logErrors;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const winston_1 = require("winston");
4
+ const logErrors = (0, winston_1.format)((info) => {
5
+ if (info instanceof Error) {
6
+ return { ...info, message: `${info.message}${info.stack ? `\n${info.stack}` : ''}` };
7
+ }
8
+ return info;
9
+ });
10
+ exports.default = logErrors;
11
+ //# sourceMappingURL=log-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-errors.js","sourceRoot":"","sources":["../../src/formats/log-errors.ts"],"names":[],"mappings":";;AAAA,qCAA0C;AAE1C,MAAM,SAAS,GAAuB,IAAA,gBAAM,EAAC,CAAC,IAAI,EAAE,EAAE;IACpD,IAAI,IAAI,YAAY,KAAK,EAAE;QACzB,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,OAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;KAChG;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC,CAAC;AAEH,kBAAe,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Logform } from 'winston';
2
+ export interface PrettyPrintOptions {
3
+ /**
4
+ * Enable or disable timestamps print if it's a boolean value. Use the given format for the timestamps if it's a string
5
+ */
6
+ timestamps?: Logform.TimestampOptions['format'] | boolean;
7
+ /**
8
+ * Enable or disable the use of colors for the log level
9
+ */
10
+ colors?: boolean;
11
+ }
12
+ declare const _default: (options?: PrettyPrintOptions) => Logform.Format;
13
+ /**
14
+ * Create a pretty print formatter for a winston logger
15
+ * @param options
16
+ */
17
+ export default _default;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const winston_1 = require("winston");
7
+ const log_errors_1 = __importDefault(require("./log-errors"));
8
+ const defaultTimestampFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
9
+ /**
10
+ * Create a pretty print formatter for a winston logger
11
+ * @param options
12
+ */
13
+ exports.default = (options = {}) => {
14
+ const { timestamps = true, colors = true } = options;
15
+ const handlers = [];
16
+ if (timestamps) {
17
+ handlers.push(winston_1.format.timestamp({
18
+ format: timestamps === true ? defaultTimestampFormat : timestamps,
19
+ }));
20
+ }
21
+ if (colors) {
22
+ handlers.push(winston_1.format.colorize());
23
+ }
24
+ handlers.push((0, log_errors_1.default)());
25
+ handlers.push(winston_1.format.printf(({ level, message, timestamp }) => {
26
+ return `${timestamps ? `[${timestamp}] ` : ''}${level}: ${message}`;
27
+ }));
28
+ return winston_1.format.combine(...handlers);
29
+ };
30
+ //# sourceMappingURL=pretty-print.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pretty-print.js","sourceRoot":"","sources":["../../src/formats/pretty-print.ts"],"names":[],"mappings":";;;;;AAAA,qCAA0C;AAC1C,8DAAqC;AAErC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAazD;;;GAGG;AACH,kBAAe,CAAC,UAA8B,EAAE,EAAkB,EAAE;IAClE,MAAM,EAAE,UAAU,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,QAAQ,GAAqB,EAAE,CAAC;IAEtC,IAAI,UAAU,EAAE;QACd,QAAQ,CAAC,IAAI,CACX,gBAAM,CAAC,SAAS,CAAC;YACf,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,UAAU;SAClE,CAAC,CACH,CAAC;KACH;IAED,IAAI,MAAM,EAAE;QACV,QAAQ,CAAC,IAAI,CAAC,gBAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;KAClC;IAED,QAAQ,CAAC,IAAI,CAAC,IAAA,oBAAS,GAAE,CAAC,CAAC;IAE3B,QAAQ,CAAC,IAAI,CACX,gBAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE;QAC9C,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,SAAmB,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,KAAK,OAAiB,EAAE,CAAC;IAC1F,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,gBAAM,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as winston from 'winston';
2
+ import * as configs from './configs';
3
+ export * as formats from './formats';
4
+ declare const createLogger: (userConfiguration?: winston.LoggerOptions) => winston.Logger;
5
+ export { createLogger, winston, configs };
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.configs = exports.winston = exports.createLogger = exports.formats = void 0;
27
+ const winston = __importStar(require("winston"));
28
+ exports.winston = winston;
29
+ const configs = __importStar(require("./configs"));
30
+ exports.configs = configs;
31
+ exports.formats = __importStar(require("./formats"));
32
+ const createLogger = (userConfiguration = {}) => {
33
+ const configuration = configs.createDefaultConfiguration();
34
+ Object.assign(configuration, userConfiguration);
35
+ return winston.createLogger(configuration);
36
+ };
37
+ exports.createLogger = createLogger;
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAaZ,0BAAO;AAZ9B,mDAAqC;AAYL,0BAAO;AAVvC,qDAAqC;AAErC,MAAM,YAAY,GAAG,CAAC,oBAA2C,EAAE,EAAkB,EAAE;IACrF,MAAM,aAAa,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAE3D,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEO,oCAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/logger",
3
- "version": "4.9.0-exp.90df253ba90fd6879eb56a720a1f80d04ff745b8",
3
+ "version": "4.9.1",
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": "./lib/index.js",
27
- "directories": {
28
- "lib": "./lib"
29
- },
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "files": [
29
+ "./dist"
30
+ ],
30
31
  "scripts": {
31
- "test": "echo \"no tests yet\""
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.9.1",
45
+ "tsconfig": "4.9.1"
46
+ },
37
47
  "engines": {
38
48
  "node": ">=14.19.1 <=18.x.x",
39
49
  "npm": ">=6.0.0"
40
50
  },
41
- "gitHead": "366eb8a0d0f06935914854c6d9c4b3fe859468e0"
51
+ "gitHead": "c8f2f0543b45dda8eadde21a0782b64d156fc786"
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;
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- const createDefaultConfiguration = require('./default-configuration');
4
- const createOutputFileConfiguration = require('./output-file-configuration');
5
-
6
- module.exports = {
7
- createDefaultConfiguration,
8
- createOutputFileConfiguration,
9
- };
@@ -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,13 +0,0 @@
1
- 'use strict';
2
-
3
- const { config } = require('winston');
4
-
5
- const LEVELS = config.npm.levels;
6
- const LEVEL_LABEL = 'silly';
7
- const LEVEL = LEVELS[LEVEL_LABEL];
8
-
9
- module.exports = {
10
- LEVEL,
11
- LEVEL_LABEL,
12
- LEVELS,
13
- };
@@ -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;
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- const prettyPrint = require('./pretty-print');
4
- const levelFilter = require('./level-filter');
5
- const excludeColors = require('./exclude-colors');
6
-
7
- module.exports = {
8
- prettyPrint,
9
- levelFilter,
10
- excludeColors,
11
- };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- const { format } = require('winston');
4
-
5
- module.exports = (...levels) => {
6
- return format((info) => (levels.some((level) => info.level.includes(level)) ? info : false))();
7
- };
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- const { format } = require('winston');
4
-
5
- module.exports = format((info) => {
6
- if (info instanceof Error) {
7
- return { ...info, message: `${info.message}${info.stack ? `\n${info.stack}` : ''}` };
8
- }
9
-
10
- return info;
11
- });
@@ -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
- };