@wdio/logger 7.19.0 → 7.20.8-alpha.504

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 CHANGED
@@ -1,6 +1,4 @@
1
- /**
2
- * environment check to allow to use this package in a web context
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AAGH,QAAA,IAAI,IAAI,KAA2B,CAAA;AAcnC,eAAe,IAAI,CAAA"}
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 = require('./web').default;
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 = require(nodeMode).default;
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
- exports.default = mode;
19
+ export default mode.default;
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,UAAU,CAAA;AA4G1B,iBAAwB,SAAS,CAAE,IAAI,EAAE,MAAM,cAwB9C;kBAxBuB,SAAS;;;;;;eAAT,SAAS;AAgFjC,oBAAY,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA"}
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
- "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 fs_1 = __importDefault(require("fs"));
7
- const loglevel_1 = __importDefault(require("loglevel"));
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) => chalk_1.default.magenta(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) => chalk_1.default.yellow(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) => chalk_1.default.cyan(log)
46
+ serialize: (log) => chalk.cyan(log)
52
47
  }];
53
- const loggers = loglevel_1.default.getLoggers();
48
+ const loggers = log.getLoggers();
54
49
  let logLevelsConfig = {};
55
50
  const logCache = new Set();
56
51
  let logFile;
57
- const originalFactory = loglevel_1.default.methodFactory;
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 = fs_1.default.createWriteStream(process.env.WDIO_LOG_PATH);
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 = (0, strip_ansi_1.default)(`${util_1.default.format.apply(this, args)}\n`);
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] = loglevel_1.default.getLogger(name);
110
+ loggers[name] = log.getLogger(name);
116
111
  loggers[name].setLevel(logLevel);
117
112
  loggers[name].methodFactory = wdioLoggerMethodFactory;
118
- loglevel_plugin_prefix_1.default.apply(loggers[name], {
113
+ prefix.apply(loggers[name], {
119
114
  template: '%t %l %n:',
120
- timestampFormatter: (date) => chalk_1.default.gray(date.toISOString()),
121
- levelFormatter: (level) => chalk_1.default[COLORS[level]](level.toUpperCase()),
122
- nameFormatter: (name) => chalk_1.default.whiteBright(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,17 +1,21 @@
1
1
  {
2
2
  "name": "@wdio/logger",
3
- "version": "7.19.0",
3
+ "version": "7.20.8-alpha.504+428a9d729",
4
4
  "description": "A helper utility for logging of WebdriverIO packages",
5
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
- "main": "./build/node",
8
+ "type": "module",
9
+ "exports": "./build/index.js",
10
+ "types": "./build/index.d.ts",
11
+ "typeScriptVersion": "3.8.3",
9
12
  "engines": {
10
- "node": ">=12.0.0"
13
+ "node": "^16.13 || >=18"
11
14
  },
12
15
  "repository": {
13
16
  "type": "git",
14
- "url": "git://github.com/webdriverio/webdriverio.git"
17
+ "url": "git://github.com/webdriverio/webdriverio.git",
18
+ "directory": "packages/wdio-logger"
15
19
  },
16
20
  "keywords": [
17
21
  "webdriver",
@@ -21,10 +25,8 @@
21
25
  "bugs": {
22
26
  "url": "https://github.com/webdriverio/webdriverio/issues"
23
27
  },
24
- "types": "./build/node.d.ts",
25
- "typeScriptVersion": "3.8.3",
26
28
  "dependencies": {
27
- "chalk": "^4.0.0",
29
+ "chalk": "^5.1.2",
28
30
  "loglevel": "^1.6.0",
29
31
  "loglevel-plugin-prefix": "^0.8.4",
30
32
  "strip-ansi": "^6.0.0"
@@ -32,5 +34,5 @@
32
34
  "publishConfig": {
33
35
  "access": "public"
34
36
  },
35
- "gitHead": "a17ba0237dcbafa8f0215534c64ff9634caf4b43"
37
+ "gitHead": "428a9d729ae6231968a60908732fa3f607d195e9"
36
38
  }