@testomatio/reporter 1.2.1-beta → 1.2.1-beta.codecept-id.2

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 (47) hide show
  1. package/README.md +61 -54
  2. package/lib/adapter/codecept.js +140 -61
  3. package/lib/adapter/cucumber/current.js +103 -60
  4. package/lib/adapter/cucumber/legacy.js +27 -12
  5. package/lib/adapter/cucumber.js +2 -2
  6. package/lib/adapter/cypress-plugin/index.js +52 -25
  7. package/lib/adapter/jasmine.js +1 -1
  8. package/lib/adapter/jest.js +49 -11
  9. package/lib/adapter/mocha.js +103 -51
  10. package/lib/adapter/playwright.js +100 -31
  11. package/lib/adapter/webdriver.js +1 -1
  12. package/lib/bin/reportXml.js +14 -13
  13. package/lib/bin/startTest.js +27 -6
  14. package/lib/client.js +193 -69
  15. package/lib/config.js +34 -0
  16. package/lib/constants.js +19 -7
  17. package/lib/data-storage.js +203 -0
  18. package/lib/fileUploader.js +128 -53
  19. package/lib/junit-adapter/adapter.js +0 -2
  20. package/lib/junit-adapter/csharp.js +3 -4
  21. package/lib/junit-adapter/index.js +3 -3
  22. package/lib/junit-adapter/java.js +35 -17
  23. package/lib/junit-adapter/javascript.js +1 -2
  24. package/lib/junit-adapter/python.js +12 -14
  25. package/lib/junit-adapter/ruby.js +1 -2
  26. package/lib/pipe/csv.js +5 -3
  27. package/lib/pipe/github.js +27 -39
  28. package/lib/pipe/gitlab.js +20 -24
  29. package/lib/pipe/html.js +317 -0
  30. package/lib/pipe/index.js +3 -1
  31. package/lib/pipe/testomatio.js +182 -55
  32. package/lib/reporter-functions.js +46 -0
  33. package/lib/reporter.js +11 -9
  34. package/lib/services/artifacts.js +57 -0
  35. package/lib/services/index.js +13 -0
  36. package/lib/services/key-values.js +58 -0
  37. package/lib/services/logger.js +311 -0
  38. package/lib/template/template-draft.hbs +249 -0
  39. package/lib/template/testomatio.hbs +388 -0
  40. package/lib/utils/pipe_utils.js +128 -0
  41. package/lib/{util.js → utils/utils.js} +145 -12
  42. package/lib/xmlReader.js +211 -122
  43. package/package.json +18 -8
  44. package/lib/_ArtifactStorageOld.js +0 -142
  45. package/lib/artifactStorage.js +0 -25
  46. package/lib/dataStorage.js +0 -180
  47. package/lib/logger.js +0 -278
@@ -1,142 +0,0 @@
1
- const debug = require('debug')('@testomatio/reporter:storage');
2
- const { join, resolve } = require('path');
3
- const fs = require('fs');
4
- const os = require('os');
5
- const uuid = require('uuid');
6
- const { TESTOMAT_ARTIFACT_SUFFIX } = require('./constants');
7
- const { specificTestInfo } = require('./util');
8
-
9
- class ArtifactStorage {
10
-
11
- constructor(params) {
12
- this.isFile = false;
13
- this.isMemory = true;
14
- this.storage = params?.toFile;
15
-
16
- if (this.storage) {
17
- // this is fine to use when you start saving artifacts;
18
- // but when you need to retrieve them, you will not know if there is "isFile" param,
19
- // because you need to create a new instance of ArtifactStorage inside client
20
- // so the solution is make it opposite to isMemory (which will be retrieved from global)
21
- this.isFile = true;
22
- this.isMemory = false;
23
- this.tmpDirFullpath = this.createTestomatTmpDir(ArtifactStorage._tmpPrefix);
24
- debug('SAVE to tmp folder mode enabled!');
25
- }
26
- }
27
-
28
- static async storeToFile(tmpDirName, artifact, testSuffix = "test") {
29
- // this assumes to use multiple files for each test. do we really want this?
30
- const suffix = TESTOMAT_ARTIFACT_SUFFIX + uuid.v4() + testSuffix;
31
- const dirpath = join(os.tmpdir(), tmpDirName);
32
- // why json?
33
- const filepath = resolve(dirpath, `${suffix}.json`);
34
-
35
- return fs.promises.appendFile(filepath, JSON.stringify(artifact));
36
- }
37
-
38
- static async artifact(artifact, context) {
39
- // TODO: mode for different pre-hooks. As variant - "all-tests" || "only_fail"
40
- // const mode = process.env.TESTOMAT_ARTIFACTS || "only_fail";
41
-
42
- // you save the artifact without specifying its source - test id
43
- if (Array.isArray(global.testomatioArtifacts)) {
44
- debug("Saving artifacts to global storage");
45
-
46
- global.testomatioArtifacts.push(artifact);
47
- }
48
-
49
- if (global?.testomatioArtifacts === undefined) {
50
- const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
51
-
52
- const testSuffix = specificTestInfo(context.test);
53
-
54
- if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
55
- debug("Saving artifacts to memory tmp folder");
56
-
57
- return ArtifactStorage.storeToFile(tmpDirNames[tmpDirNames.length - 1], artifact, testSuffix);
58
- }
59
- }
60
- }
61
-
62
- async artifactByTestName(test) {
63
- const list = [];
64
-
65
- if (this.isFile && this.tmpDirFullpath) {
66
- const files = fs.readdirSync(this.tmpDirFullpath);
67
-
68
- for (const file of files) {
69
- if (file.includes(test)) {
70
- const buff = await fs.promises.readFile(`${this.tmpDirFullpath }/${ file}`);
71
-
72
- list.push(JSON.parse(buff.toString()));
73
- }
74
- }
75
- }
76
-
77
- return list;
78
- }
79
-
80
- // returns all the content from all files; do we really need it?
81
- async tmpContents() {
82
- const contents = [];
83
-
84
- if (this.isFile && this.tmpDirFullpath) {
85
- const files = fs.readdirSync(this.tmpDirFullpath);
86
-
87
- for (const file of files) {
88
- const buff = await fs.promises.readFile(`${this.tmpDirFullpath }/${ file}`);
89
- const content = buff.toString();
90
-
91
- contents.push(content);
92
- }
93
- }
94
-
95
- return contents;
96
- }
97
-
98
- createTestomatTmpDir(clientPrefix) {
99
- return fs.mkdtempSync(join(os.tmpdir(), clientPrefix));
100
- }
101
-
102
- clearTmpDirByName(name) {
103
- const tmpDirPath = join(os.tmpdir(), name);
104
-
105
- if (fs.existsSync(tmpDirPath)) {
106
- fs.rmSync(tmpDirPath, { recursive: true });
107
- debug(` Testomat tmpDir = ${tmpDirPath} was deleted successfully!`);
108
-
109
-
110
- }
111
- }
112
-
113
- // no need to use multiple dirs; we can implement it later if required
114
- static tmpTestomatDirNames() {
115
- const subname = ArtifactStorage._tmpPrefix || "tsmt_reporter";
116
-
117
- return fs.readdirSync(os.tmpdir(), { withFileTypes: true })
118
- .filter((item) => item.isDirectory())
119
- .map((item) => item.name)
120
- .filter((name) => name.includes(subname));
121
- }
122
-
123
- cleanup() {
124
- // when you do a cleanup, I know nothing about isFile param
125
- if (this.isFile && this.tmpDirFullpath) {
126
- const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
127
-
128
- if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
129
- for (const name of tmpDirNames) {
130
- this.clearTmpDirByName(name);
131
- }
132
- }
133
- }
134
- else {
135
- debug("The tmp folder has not been created! Nothing to delete");
136
- }
137
- }
138
- }
139
-
140
- ArtifactStorage._tmpPrefix = "tsmt_reporter";
141
-
142
- module.exports = ArtifactStorage;
@@ -1,25 +0,0 @@
1
- // const debug = require('debug')('@testomatio/reporter:logger');
2
- const { DataStorage } = require('./dataStorage');
3
-
4
- class ArtifactStorage {
5
- constructor(params = {}) {
6
- this.dataStorage = new DataStorage('artifact', params);
7
-
8
- // singleton
9
- if (!ArtifactStorage.instance) {
10
- ArtifactStorage.instance = this;
11
- }
12
- }
13
-
14
- save(data, context = null) {
15
- this.dataStorage.putData(data, context);
16
- }
17
-
18
- get(context) {
19
- this.dataStorage.getData(context);
20
- }
21
- }
22
-
23
- ArtifactStorage.instance = null;
24
-
25
- module.exports = new ArtifactStorage();
@@ -1,180 +0,0 @@
1
- const debug = require('debug')('@testomatio/reporter:storage');
2
- const fs = require('fs');
3
- const path = require('path');
4
- const os = require('os');
5
- const { join } = require('path');
6
- const JestReporter = require('./adapter/jest');
7
- const { TESTOMAT_TMP_STORAGE } = require('./constants');
8
- const { fileSystem } = require('./util');
9
-
10
- class DataStorage {
11
- /**
12
- * Creates data storage instance for specific data type.
13
- * Stores data to global variable or to file depending on what is applicable for current test runner.
14
- * dataType: 'log' | 'artifact' | ...
15
- * @param {*} dataType storage type (like 'log', 'artifact'); could be any string, used only to define file path
16
- * @param {*} params
17
- */
18
- constructor(dataType, params = {}) {
19
- if (!dataType) throw new Error('Data type is required when creating data storage');
20
- this.dataType = dataType || 'data';
21
- this.dataDirName = `${dataType}s`;
22
- this.isFileStorage = params?.isFileStorage ?? !global.testomatioDataStore;
23
-
24
- /*
25
- FYI:
26
- If this storage instance is used within test runner, it works fine.
27
- But if, for example, we create storage instance inside the testomatio client (to get stored data),
28
- the environment could be different (not already a test runner env).
29
- Thus, checking environment is only reasonable when you put data to starage
30
- and potentially useless when get data from storage
31
- */
32
- this.runningEnvironment = this.getRunningEnviroment();
33
- if (this.runningEnvironment === 'jest') this.isFileStorage = true;
34
-
35
- if (this.isFileStorage) {
36
- this.dataDirPath = path.join(TESTOMAT_TMP_STORAGE.mainDir, this.dataDirName);
37
- fileSystem.createDir(this.dataDirPath);
38
- }
39
-
40
- debug(`Data storage mode: ${this.isFileStorage ? 'file' : 'memory'}`);
41
- }
42
-
43
- // TODO: implement
44
- getTestIdFromContext(context) { // eslint-disable-line
45
- // eslint-disable-line
46
- // return testId;
47
- }
48
-
49
- /**
50
- * Try to define the running environment. Not 100% reliable and used as additional check
51
- * @returns jest | mocha | ...
52
- */
53
- getRunningEnviroment() {
54
- if (process.env.JEST_WORKER_ID) return 'jest';
55
- try {
56
- // @ts-expect-error mocha is defined only in mocha environment
57
- if (typeof mocha !== 'undefined') return 'mocha';
58
- } catch (e) {
59
- // ignore
60
- }
61
- return undefined;
62
- }
63
-
64
- /**
65
- * Puts any data to storage (file or global variable)
66
- * @param {*} data anything you want to store
67
- * @param {*} context could be testId or any context (test, suite, etc) which is used to define testId
68
- * @returns
69
- */
70
- putData(data, context = null) {
71
- // this.isFileStorage = !global.testomatioDataStore;
72
-
73
- let testId = null;
74
- if (typeof context === 'string') {
75
- testId = context;
76
- } else {
77
- // TODO: derive testId from context
78
- // testId = context...
79
- }
80
-
81
- // try to get testId for Jest
82
- if (this.runningEnvironment === 'jest') testId = testId ?? JestReporter.getIdOfCurrentlyRunningTest();
83
-
84
- // if testId is not provided, data is be saved to `{dataType}_other` file;
85
- if (!testId) testId = 'other';
86
-
87
- if (this.isFileStorage) {
88
- this._putDataToFile(data, testId);
89
- } else {
90
- this._putDataToGlobalVar(data, testId);
91
- }
92
- }
93
-
94
- /**
95
- * Returns data, stored for specific testId (or data which was stored without test id specified)
96
- *
97
- * (Don't try to guess the execution environment (e.g. test runner) inside this method, it could be any)
98
- * @param {*} context could be testId or any context (test, suite, etc) which is used to define testId
99
- * @returns
100
- */
101
- getData(context) {
102
- let testId = null;
103
- if (typeof context === 'string') {
104
- testId = context;
105
- } else {
106
- // TODO: derive testId from context
107
- // testId = context...
108
- }
109
-
110
- if (!testId) {
111
- debug(`Cannot get test id from passed context:\n}`, context);
112
- }
113
-
114
- if (this.isFileStorage) {
115
- return this._getDataFromFile(testId);
116
- }
117
- if (global?.testomatioDataStore) {
118
- return this._getDataFromGlobalVar(testId);
119
- }
120
- debug(`No ${this.dataType} data for test id ${testId} in both file and global variable`);
121
- return null;
122
- }
123
-
124
- _getDataFromGlobalVar(testId) {
125
- try {
126
- if (global?.testomatioDataStore[this.dataDirName]) {
127
- const testData = global.testomatioDataStore[this.dataDirName][testId];
128
- debug(`Data for test id ${testId}:\n${testData}`);
129
- return testData;
130
- }
131
- debug(`No ${this.dataType} data for test id ${testId}`);
132
- return null;
133
- } catch (e) {
134
- // there could be no data, ignore
135
- }
136
- }
137
-
138
- _getDataFromFile(testId) {
139
- try {
140
- const filepath = join(TESTOMAT_TMP_STORAGE.mainDir, `${this.dataType}_${testId}`);
141
- if (fs.existsSync(filepath)) {
142
- const testData = fs.readFileSync(filepath, 'utf-8');
143
- debug(`Data for test id ${testId}:\n${testData}`);
144
- return testData;
145
- }
146
- debug(`No ${this.dataType} data for test id ${testId}`);
147
- return null;
148
- } catch (e) {
149
- // there could be no data, ignore
150
- }
151
- return null;
152
- }
153
-
154
- _putDataToGlobalVar(data, testId) {
155
- debug('Saving data to global variable for test', testId, ':\n', data, '\n');
156
- global.testomatioDataStore[this.dataDirName] = {};
157
- global.testomatioDataStore[this.dataDirName][testId] = data;
158
- }
159
-
160
- _putDataToFile(data, testId) {
161
- if (typeof data !== 'string') data = JSON.stringify(data);
162
- const filename = `${this.dataType}_${testId}`;
163
- const filepath = join(TESTOMAT_TMP_STORAGE.mainDir, filename);
164
- debug('Saving data to file for test', testId, 'to', filepath, ':\n', data, '\n');
165
-
166
- // TODO: handle multiple invocations of JSON.stringify.
167
- // UPD: not actual because decided not to use it - it created extra wrapping quotes "" and // (escaped slashes)
168
- fs.appendFileSync(filepath, data + os.EOL, 'utf-8');
169
- }
170
- }
171
-
172
- module.exports.DataStorage = DataStorage;
173
-
174
- // TODO: consider using fs promises instead of writeSync/appendFileSync to
175
- // prevent blocking and improve performance (probably queue usage will be required)
176
-
177
- // TODO: rewrite client - everything regarding storing artifacts
178
- // TODO: try to define adapter inside client
179
- // TODO: use .env
180
- // TODO: ability to intercept multiple loggers
package/lib/logger.js DELETED
@@ -1,278 +0,0 @@
1
- const chalk = require('chalk');
2
- const debug = require('debug')('@testomatio/reporter:logger');
3
- const { DataStorage } = require('./dataStorage');
4
-
5
- const LOG_METHODS = ['assert', 'debug', 'error', 'info', 'log', 'trace', 'warn'];
6
- const LEVELS = {
7
- ALL: { severity: 1, color: '' },
8
- VERBOSE: { severity: 3, color: 'grey' },
9
- TRACE: { severity: 5, color: 'grey' },
10
- DEBUG: { severity: 7, color: 'cyan' },
11
- INFO: { severity: 9, color: 'black' },
12
- LOG: { severity: 11, color: 'black' },
13
- WARN: { severity: 13, color: 'yellow' },
14
- ERROR: { severity: 15, color: 'red' },
15
- };
16
-
17
- /**
18
- * Logger allows to:
19
- * 1. Intercept logs from user logger (console.log, etc) and store them.
20
- * 2. Output logs to console (actually, logger functionality).
21
- * 3. Varied syntax.
22
- */
23
- class Logger {
24
- // _originalUserLogger used to output logs to console by the user logger
25
- // _loggerToIntercept intercepted and reassigned immediately when added
26
-
27
- constructor(params = {}) {
28
- // set default logger to be used in log, warn, error, etc methods
29
- this._originalUserLogger = { ...console };
30
-
31
- this.dataStorage = new DataStorage('log', params);
32
- this.logLevel = process?.env?.LOG_LEVEL?.toUpperCase() || 'ALL';
33
-
34
- // commented because prefer to use "intercept" method
35
- // if (params?.logger) this._loggerToIntercept = params.logger;
36
-
37
- this.intercept(this._loggerToIntercept);
38
-
39
- // singleton
40
- if (!Logger.instance) {
41
- Logger.instance = this;
42
- }
43
- }
44
-
45
- /**
46
- * Tagget template literal. Allows to use different syntaxes:
47
- * 1. Tagget template: $`text ${someVar}`
48
- * 2. Standard: $(`text ${someVar}`)
49
- * 3. Standard with multiple arguments: $('text', someVar)
50
- */
51
- _log(strings, ...args) {
52
- let logs;
53
- // this block means tagged template is used (syntax like $`text ${someVar}`)
54
- if (Array.isArray(strings) && strings.length === args.length + 1) {
55
- logs = strings.reduce(
56
- (result, current, index) =>
57
- result +
58
- current +
59
- // strings are splitted by args when use tagged template, thus we add arg after each string
60
- // it looks like: `string1 arg1 string2 arg2 string3`
61
- (args[index] !== undefined // eslint-disable-line no-nested-ternary
62
- ? typeof args[index] === 'string'
63
- ? args[index] // add arg as it is
64
- : this._strinfifyLogs(args[index]) // stringify arg
65
- : ' '), // add space if no arg after string
66
- // initial accumulator value
67
- '',
68
- );
69
- } else {
70
- // this block means arguments syntax is used (syntax like $('text', someVar))
71
- // in this case strings represents just a first argument
72
- logs = this._strinfifyLogs(strings, ...args);
73
- }
74
- this.dataStorage.putData(logs);
75
- }
76
-
77
- /**
78
- * Allows you to define a step inside a test. Step name is attached to the report and
79
- * helps to understand the test flow.
80
- * @param {*} strings
81
- * @param {...any} values
82
- */
83
- step(strings, ...values) {
84
- let logs = '';
85
- for (let i = 0; i < strings.length; i++) {
86
- logs += strings[i];
87
- if (i < values.length) {
88
- logs += values[i];
89
- }
90
- }
91
- logs = chalk.blue(`> ${logs}`);
92
- this.dataStorage.putData(logs);
93
- }
94
-
95
- /**
96
- *
97
- * @param {*} context testId or test context from test runner
98
- * @returns
99
- */
100
- getLogs(context) {
101
- return this.dataStorage.getData(context);
102
- }
103
-
104
- _strinfifyLogs(...args) {
105
- const logs = [];
106
- // stringify everything except strings
107
- for (const arg of args) {
108
- if (typeof arg === 'string') {
109
- logs.push(arg);
110
- } else {
111
- try {
112
- // eslint-disable-next-line no-unused-expressions
113
- this.prettyObjects ? logs.push(JSON.stringify(arg, null, 2)) : logs.push(JSON.stringify(arg));
114
- } catch (e) {
115
- debug('Error while stringify object', e);
116
- logs.push(arg);
117
- }
118
- }
119
- }
120
- return logs.join(' ');
121
- }
122
-
123
- assert(...args) {
124
- const level = 'ERROR';
125
- const severity = LEVELS[level].severity;
126
- if (severity < LEVELS[this.logLevel]?.severity) return;
127
-
128
- const logs = this._strinfifyLogs(...args);
129
- this.dataStorage.putData(logs);
130
- try {
131
- this._originalUserLogger.log(`Assertion result: `, ...args);
132
- } catch (e) {
133
- // method could be unexisting, ignore error
134
- }
135
- }
136
-
137
- debug(...args) {
138
- const level = 'DEBUG';
139
- const severity = LEVELS[level].severity;
140
- if (severity < LEVELS[this.logLevel]?.severity) return;
141
-
142
- if (this.logLevel === 'error' || this.logLevel === 'warn') return;
143
- const logs = this._strinfifyLogs(...args);
144
- const colorizedLogs = chalk[LEVELS[level].color](logs);
145
- this.dataStorage.putData(colorizedLogs);
146
- try {
147
- this._originalUserLogger.debug(...args);
148
- } catch (e) {
149
- // method could be unexisting, ignore error
150
- }
151
- }
152
-
153
- error(...args) {
154
- const level = 'ERROR';
155
- const severity = LEVELS[level].severity;
156
- if (severity < LEVELS[this.logLevel]?.severity) return;
157
-
158
- const logs = this._strinfifyLogs(...args);
159
- const colorizedLogs = chalk[LEVELS[level].color](logs);
160
- this.dataStorage.putData(colorizedLogs);
161
- try {
162
- this._originalUserLogger.error(...args);
163
- } catch (e) {
164
- // method could be unexisting, ignore error
165
- }
166
- }
167
-
168
- info(...args) {
169
- const level = 'INFO';
170
- const severity = LEVELS[level].severity;
171
- if (severity < LEVELS[this.logLevel]?.severity) return;
172
-
173
- const logs = this._strinfifyLogs(...args);
174
- this.dataStorage.putData(logs);
175
- try {
176
- this._originalUserLogger.info(...args);
177
- } catch (e) {
178
- // method could be unexisting, ignore error
179
- }
180
- }
181
-
182
- log(...args) {
183
- const level = 'INFO';
184
- const severity = LEVELS[level].severity;
185
- if (severity < LEVELS[this.logLevel]?.severity) return;
186
-
187
- const logs = this._strinfifyLogs(...args);
188
- this.dataStorage.putData(logs);
189
- try {
190
- this._originalUserLogger.log(...args);
191
- } catch (e) {
192
- // method could be unexisting, ignore error
193
- }
194
- }
195
-
196
- trace(...args) {
197
- const level = 'TRACE';
198
- const severity = LEVELS[level].severity;
199
- if (severity < LEVELS[this.logLevel]?.severity) return;
200
-
201
- const logs = this._strinfifyLogs(...args);
202
- const colorizedLogs = chalk[LEVELS[level].color](logs);
203
- this.dataStorage.putData(colorizedLogs);
204
- try {
205
- this._originalUserLogger.trace(...args);
206
- } catch (e) {
207
- // method could be unexisting, ignore error
208
- }
209
- }
210
-
211
- warn(...args) {
212
- const level = 'WARN';
213
- const severity = LEVELS[level].severity;
214
- if (severity < LEVELS[this.logLevel]?.severity) return;
215
-
216
- const logs = this._strinfifyLogs(...args);
217
- const colorizedLogs = chalk[LEVELS[level].color](logs);
218
- this.dataStorage.putData(colorizedLogs);
219
- try {
220
- this._originalUserLogger.warn(...args);
221
- } catch (e) {
222
- // method could be unexisting, ignore error
223
- }
224
- }
225
-
226
- /**
227
- * Intercepts user logger messages.
228
- * When call this method, Logger start to control the user logger,
229
- * but almost nothing is changed for user ragarding the console output (like log level set by user)
230
- * (until multiple loggers are intercepted,
231
- * in this case only the last intercepted logger will be used as user console output).
232
- * @param {*} userLogger
233
- */
234
- intercept(userLogger) {
235
- if (!userLogger) return;
236
- debug(`Intercepting user logger`);
237
-
238
- // save original user logger to use it for logging (last intercepted will be used for console output)
239
- this._originalUserLogger = { ...userLogger };
240
- this._loggerToIntercept = userLogger;
241
-
242
- /*
243
- override user logger (any, e.g. console) methods to intercept log messages
244
- this._loggerToIntercept = this; could be used, but decided to override only output methods
245
- */
246
- for (const method of LOG_METHODS) {
247
- /*
248
- decided to comment next code line because its better to create method even if it does not exist in user logger;
249
- on method invocation, we will store the data anyway and catch block will prevent potential errors
250
- */
251
- // if (!this._loggerToIntercept[method]) continue;
252
- this._loggerToIntercept[method] = (...args) => this[method](...args);
253
- }
254
- }
255
-
256
- /**
257
- * Allows to configure logger. Make sure you do it before the logger usage in your code.
258
- *
259
- * @param {Object} [config={}] - The configuration object.
260
- * @param {string} [config.logLevel] - The desired log level. Valid values are 'DEBUG', 'INFO', 'WARN', and 'ERROR'.
261
- * @param {boolean} [config.prettyObjects] - Specifies whether to enable pretty printing of objects.
262
- * @returns {void}
263
- */
264
- configure(config = {}) {
265
- if (!config) return;
266
- if (config.prettyObjects) this.prettyObjects = config.prettyObjects;
267
- if (config.logLevel) this.logLevel = config.logLevel.toUpperCase();
268
- }
269
- }
270
-
271
- Logger.instance = null;
272
-
273
- // module.exports.Logger = Logger;
274
- module.exports = new Logger();
275
-
276
- // TODO: parse passed arguments as {level: 'str', message: 'str'} because some loggers use such syntax;
277
- // upd: did not face such loggers, but still could be useful
278
-