@wdio/logger 5.9.0 → 5.12.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.
package/build/index.js CHANGED
@@ -5,24 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- /**
9
- * environment check to allow to use this package in a web context
10
- */
11
- // By default, import the web code using a literal require, so that in webpack
12
- // contexts, it will always be bundled
13
- let mode = require('./web').default; // Then, if we're in a Node.js context, require the node version of this module
14
- // using a variable, so that it will _not_ be included in a bundle, either
15
- // during compilation or execution
16
-
8
+ let mode = require('./web').default;
17
9
 
18
10
  if (typeof process !== 'undefined' && typeof process.release !== 'undefined' && process.release.name === 'node') {
19
11
  const nodeMode = './node';
20
12
  mode = require(nodeMode).default;
21
- } // The net result will be that in a Node context, we'll have required both
22
- // files but will use the correct one, and in the web context, we'll have only
23
- // required the web file, thus ensuring that the Node file and related
24
- // dependencies will not be bundled inadvertently.
25
-
13
+ }
26
14
 
27
15
  var _default = mode;
28
16
  exports.default = _default;
package/build/node.js CHANGED
@@ -19,6 +19,8 @@ var _stripAnsi = _interopRequireDefault(require("strip-ansi"));
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
+ _loglevelPluginPrefix.default.reg(_loglevel.default);
23
+
22
24
  const DEFAULT_LEVEL = 'trace';
23
25
  const COLORS = {
24
26
  error: 'red',
@@ -33,27 +35,15 @@ const matches = {
33
35
  RESULT: 'RESULT'
34
36
  };
35
37
  const SERIALIZERS = [{
36
- /**
37
- * display error stack
38
- */
39
38
  matches: err => err instanceof Error,
40
39
  serialize: err => err.stack
41
40
  }, {
42
- /**
43
- * color commands blue
44
- */
45
41
  matches: log => log === matches.COMMAND,
46
42
  serialize: log => _chalk.default.magenta(log)
47
43
  }, {
48
- /**
49
- * color data yellow
50
- */
51
44
  matches: log => log === matches.DATA,
52
45
  serialize: log => _chalk.default.yellow(log)
53
46
  }, {
54
- /**
55
- * color result cyan
56
- */
57
47
  matches: log => log === matches.RESULT,
58
48
  serialize: log => _chalk.default.cyan(log)
59
49
  }];
@@ -66,17 +56,9 @@ const originalFactory = _loglevel.default.methodFactory;
66
56
  _loglevel.default.methodFactory = function (methodName, logLevel, loggerName) {
67
57
  const rawMethod = originalFactory(methodName, logLevel, loggerName);
68
58
  return (...args) => {
69
- /**
70
- * create logFile lazily
71
- */
72
59
  if (!logFile && process.env.WDIO_LOG_PATH) {
73
60
  logFile = _fs.default.createWriteStream(process.env.WDIO_LOG_PATH);
74
61
  }
75
- /**
76
- * split `prefixer: value` sting to `prefixer: ` and `value`
77
- * so that SERIALIZERS can match certain string
78
- */
79
-
80
62
 
81
63
  const match = Object.values(matches).filter(x => args[0].endsWith(`: ${x}`))[0];
82
64
 
@@ -97,9 +79,6 @@ _loglevel.default.methodFactory = function (methodName, logLevel, loggerName) {
97
79
  const logText = (0, _stripAnsi.default)(`${_util.default.format.apply(this, args)}\n`);
98
80
 
99
81
  if (logFile && logFile.writable) {
100
- /**
101
- * empty logging cache if stuff got logged before
102
- */
103
82
  if (logCache.size) {
104
83
  logCache.forEach(log => logFile.write(log));
105
84
  logCache.clear();
@@ -121,9 +100,6 @@ _loglevelPluginPrefix.default.apply(_loglevel.default, {
121
100
  });
122
101
 
123
102
  function getLogger(name) {
124
- /**
125
- * check if logger was already initiated
126
- */
127
103
  if (loggers[name]) {
128
104
  return loggers[name];
129
105
  }
@@ -139,11 +115,6 @@ function getLogger(name) {
139
115
  loggers[name].setLevel(logLevel);
140
116
  return loggers[name];
141
117
  }
142
- /**
143
- * Wait for writable stream to be flushed.
144
- * Calling this prevents part of the logs in the very env to be lost.
145
- */
146
-
147
118
 
148
119
  getLogger.waitForBuffer = async () => new Promise(resolve => {
149
120
  if (logFile && Array.isArray(logFile.writableBuffer) && logFile.writableBuffer.length !== 0) {
@@ -159,32 +130,17 @@ getLogger.waitForBuffer = async () => new Promise(resolve => {
159
130
  getLogger.setLevel = (name, level) => loggers[name].setLevel(level);
160
131
 
161
132
  getLogger.setLogLevelsConfig = (logLevels = {}, wdioLogLevel = DEFAULT_LEVEL) => {
162
- /**
163
- * set log level
164
- */
165
133
  if (process.env.WDIO_LOG_LEVEL === undefined) {
166
134
  process.env.WDIO_LOG_LEVEL = wdioLogLevel;
167
135
  }
168
136
 
169
137
  logLevelsConfig = {};
170
- /**
171
- * build logLevelsConfig object
172
- */
173
-
174
138
  Object.entries(logLevels).forEach(([logName, logLevel]) => {
175
139
  const logLevelName = getLogLevelName(logName);
176
140
  logLevelsConfig[logLevelName] = logLevel;
177
141
  });
178
- /**
179
- * set log level for each logger
180
- */
181
-
182
142
  Object.keys(loggers).forEach(logName => {
183
143
  const logLevelName = getLogLevelName(logName);
184
- /**
185
- * either apply log level from logLevels object or use global logLevel
186
- */
187
-
188
144
  const logLevel = typeof logLevelsConfig[logLevelName] !== 'undefined' ? logLevelsConfig[logLevelName] : process.env.WDIO_LOG_LEVEL;
189
145
  loggers[logName].setLevel(logLevel);
190
146
  });
package/build/web.js CHANGED
@@ -7,18 +7,13 @@ exports.default = getLogger;
7
7
 
8
8
  function getLogger(component) {
9
9
  return ['error', 'warn', 'info', 'debug', 'trace', 'silent'].reduce((acc, cur) => {
10
- // check if the method is available on console (web doesn't have
11
- // 'silent', for example) before adding to acc
12
- // eslint-disable-next-line no-console
13
10
  if (console[cur]) {
14
- // eslint-disable-next-line no-console
15
11
  acc[cur] = console[cur].bind(console, `${component}:`);
16
12
  }
17
13
 
18
14
  return acc;
19
15
  }, {});
20
- } // logging interface expects a 'setLevel' method
21
-
16
+ }
22
17
 
23
18
  getLogger.setLevel = () => {};
24
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/logger",
3
- "version": "5.9.0",
3
+ "version": "5.12.1",
4
4
  "description": "A helper utility for logging of WebdriverIO packages",
5
5
  "author": "Christian Bromann <christian@saucelabs.com>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/master/packages/wdio-logger",
@@ -32,11 +32,11 @@
32
32
  "dependencies": {
33
33
  "chalk": "^2.3.0",
34
34
  "loglevel": "^1.6.0",
35
- "loglevel-plugin-prefix": "^0.5.3",
36
- "strip-ansi": "^4.0.0"
35
+ "loglevel-plugin-prefix": "^0.8.4",
36
+ "strip-ansi": "^5.2.0"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "6339dc411df997530375eda47b8a4b735bcd6c2c"
41
+ "gitHead": "848151e5fdcb8b694c1a273b9b69852c22875687"
42
42
  }