@wdio/logger 7.17.3 → 8.0.0-alpha.219
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/build/index.d.ts +3 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -6
- package/build/node.d.ts.map +1 -1
- package/build/node.js +20 -26
- package/build/web.js +1 -4
- package/package.json +8 -7
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare let mode: any;
|
|
5
|
-
export default mode;
|
|
1
|
+
import type loggerType from './node';
|
|
2
|
+
declare const _default: typeof loggerType;
|
|
3
|
+
export default _default;
|
|
6
4
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,UAAU,MAAM,QAAQ,CAAA;;AAqBpC,wBAAgD"}
|
package/build/index.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* istanbul ignore file */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
2
|
/**
|
|
5
3
|
* environment check to allow to use this package in a web context
|
|
6
4
|
*/
|
|
7
5
|
// By default, import the web code using a literal require, so that in webpack
|
|
8
6
|
// contexts, it will always be bundled
|
|
9
|
-
let mode =
|
|
7
|
+
let mode = await import('./web.js');
|
|
10
8
|
// Then, if we're in a Node.js context, require the node version of this module
|
|
11
9
|
// using a variable, so that it will _not_ be included in a bundle, either
|
|
12
10
|
// during compilation or execution
|
|
13
11
|
if (typeof process !== 'undefined' && typeof process.release !== 'undefined' && process.release.name === 'node') {
|
|
14
|
-
const nodeMode = './node';
|
|
15
|
-
mode =
|
|
12
|
+
const nodeMode = './node.js';
|
|
13
|
+
mode = await import(nodeMode);
|
|
16
14
|
}
|
|
17
15
|
// The net result will be that in a Node context, we'll have required both
|
|
18
16
|
// files but will use the correct one, and in the web context, we'll have only
|
|
19
17
|
// required the web file, thus ensuring that the Node file and related
|
|
20
18
|
// dependencies will not be bundled inadvertently.
|
|
21
|
-
|
|
19
|
+
export default mode.default;
|
package/build/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAGA,OAAO,GAAG,MAAM,UAAU,CAAA;AA2G1B,iBAAwB,SAAS,CAAE,IAAI,EAAE,MAAM,cAwB9C;kBAxBuB,SAAS;;;;;;eAAT,SAAS;AAgFjC,oBAAY,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA"}
|
package/build/node.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const util_1 = __importDefault(require("util"));
|
|
9
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
-
const loglevel_plugin_prefix_1 = __importDefault(require("loglevel-plugin-prefix"));
|
|
11
|
-
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
12
|
-
loglevel_plugin_prefix_1.default.reg(loglevel_1.default);
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import util from 'node:util';
|
|
3
|
+
import log from 'loglevel';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import prefix from 'loglevel-plugin-prefix';
|
|
6
|
+
import ansiStrip from 'strip-ansi';
|
|
7
|
+
prefix.reg(log);
|
|
13
8
|
const DEFAULT_LEVEL = process.env.WDIO_DEBUG
|
|
14
9
|
? 'trace'
|
|
15
10
|
: 'info';
|
|
@@ -36,25 +31,25 @@ const SERIALIZERS = [{
|
|
|
36
31
|
* color commands blue
|
|
37
32
|
*/
|
|
38
33
|
matches: (log) => log === matches.COMMAND,
|
|
39
|
-
serialize: (log) =>
|
|
34
|
+
serialize: (log) => chalk.magenta(log)
|
|
40
35
|
}, {
|
|
41
36
|
/**
|
|
42
37
|
* color data yellow
|
|
43
38
|
*/
|
|
44
39
|
matches: (log) => log === matches.DATA,
|
|
45
|
-
serialize: (log) =>
|
|
40
|
+
serialize: (log) => chalk.yellow(log)
|
|
46
41
|
}, {
|
|
47
42
|
/**
|
|
48
43
|
* color result cyan
|
|
49
44
|
*/
|
|
50
45
|
matches: (log) => log === matches.RESULT,
|
|
51
|
-
serialize: (log) =>
|
|
46
|
+
serialize: (log) => chalk.cyan(log)
|
|
52
47
|
}];
|
|
53
|
-
const loggers =
|
|
48
|
+
const loggers = log.getLoggers();
|
|
54
49
|
let logLevelsConfig = {};
|
|
55
50
|
const logCache = new Set();
|
|
56
51
|
let logFile;
|
|
57
|
-
const originalFactory =
|
|
52
|
+
const originalFactory = log.methodFactory;
|
|
58
53
|
const wdioLoggerMethodFactory = function (methodName, logLevel, loggerName) {
|
|
59
54
|
const rawMethod = originalFactory(methodName, logLevel, loggerName);
|
|
60
55
|
return (...args) => {
|
|
@@ -62,7 +57,7 @@ const wdioLoggerMethodFactory = function (methodName, logLevel, loggerName) {
|
|
|
62
57
|
* create logFile lazily
|
|
63
58
|
*/
|
|
64
59
|
if (!logFile && process.env.WDIO_LOG_PATH) {
|
|
65
|
-
logFile =
|
|
60
|
+
logFile = fs.createWriteStream(process.env.WDIO_LOG_PATH);
|
|
66
61
|
}
|
|
67
62
|
/**
|
|
68
63
|
* split `prefixer: value` sting to `prefixer: ` and `value`
|
|
@@ -81,7 +76,7 @@ const wdioLoggerMethodFactory = function (methodName, logLevel, loggerName) {
|
|
|
81
76
|
}
|
|
82
77
|
return arg;
|
|
83
78
|
});
|
|
84
|
-
const logText = (
|
|
79
|
+
const logText = ansiStrip(`${util.format.apply(this, args)}\n`);
|
|
85
80
|
if (logFile && logFile.writable) {
|
|
86
81
|
/**
|
|
87
82
|
* empty logging cache if stuff got logged before
|
|
@@ -100,7 +95,7 @@ const wdioLoggerMethodFactory = function (methodName, logLevel, loggerName) {
|
|
|
100
95
|
rawMethod(...args);
|
|
101
96
|
};
|
|
102
97
|
};
|
|
103
|
-
function getLogger(name) {
|
|
98
|
+
export default function getLogger(name) {
|
|
104
99
|
/**
|
|
105
100
|
* check if logger was already initiated
|
|
106
101
|
*/
|
|
@@ -112,18 +107,17 @@ function getLogger(name) {
|
|
|
112
107
|
if (logLevelsConfig[logLevelName]) {
|
|
113
108
|
logLevel = logLevelsConfig[logLevelName];
|
|
114
109
|
}
|
|
115
|
-
loggers[name] =
|
|
110
|
+
loggers[name] = log.getLogger(name);
|
|
116
111
|
loggers[name].setLevel(logLevel);
|
|
117
112
|
loggers[name].methodFactory = wdioLoggerMethodFactory;
|
|
118
|
-
|
|
113
|
+
prefix.apply(loggers[name], {
|
|
119
114
|
template: '%t %l %n:',
|
|
120
|
-
timestampFormatter: (date) =>
|
|
121
|
-
levelFormatter: (level) =>
|
|
122
|
-
nameFormatter: (name) =>
|
|
115
|
+
timestampFormatter: (date) => chalk.gray(date.toISOString()),
|
|
116
|
+
levelFormatter: (level) => chalk[COLORS[level]](level.toUpperCase()),
|
|
117
|
+
nameFormatter: (name) => chalk.whiteBright(name)
|
|
123
118
|
});
|
|
124
119
|
return loggers[name];
|
|
125
120
|
}
|
|
126
|
-
exports.default = getLogger;
|
|
127
121
|
/**
|
|
128
122
|
* Wait for writable stream to be flushed.
|
|
129
123
|
* Calling this prevents part of the logs in the very env to be lost.
|
package/build/web.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* istanbul ignore file */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
2
|
const LOG_METHODS = ['error', 'warn', 'info', 'debug', 'trace', 'silent'];
|
|
5
|
-
function getLogger(component) {
|
|
3
|
+
export default function getLogger(component) {
|
|
6
4
|
return LOG_METHODS.reduce((acc, cur) => {
|
|
7
5
|
const prop = cur;
|
|
8
6
|
// check if the method is available on console (web doesn't have
|
|
@@ -16,7 +14,6 @@ function getLogger(component) {
|
|
|
16
14
|
return acc;
|
|
17
15
|
}, {});
|
|
18
16
|
}
|
|
19
|
-
exports.default = getLogger;
|
|
20
17
|
// logging interface expects a 'setLevel' method
|
|
21
18
|
getLogger.setLevel = () => { };
|
|
22
19
|
getLogger.setLogLevelsConfig = () => { };
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/logger",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-alpha.219+4aab2cef1",
|
|
4
4
|
"description": "A helper utility for logging of WebdriverIO packages",
|
|
5
|
-
"author": "Christian Bromann <
|
|
5
|
+
"author": "Christian Bromann <mail@bromann.dev>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-logger",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": "./build/index.js",
|
|
10
|
+
"types": "./build/index.d.ts",
|
|
11
|
+
"typeScriptVersion": "3.8.3",
|
|
9
12
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
13
|
+
"node": "^16.13 || >=18"
|
|
11
14
|
},
|
|
12
15
|
"repository": {
|
|
13
16
|
"type": "git",
|
|
@@ -21,8 +24,6 @@
|
|
|
21
24
|
"bugs": {
|
|
22
25
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
23
26
|
},
|
|
24
|
-
"types": "./build/node.d.ts",
|
|
25
|
-
"typeScriptVersion": "3.8.3",
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"chalk": "^4.0.0",
|
|
28
29
|
"loglevel": "^1.6.0",
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"publishConfig": {
|
|
33
34
|
"access": "public"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "4aab2cef1b8b195ac8cc611f28b1fd54e4ba3443"
|
|
36
37
|
}
|