Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wdio/logger

Package Overview
Dependencies
Maintainers
3
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wdio/logger - npm Package Compare versions

Comparing version 8.11.0 to 8.16.17

7

build/node.d.ts
import log from 'loglevel';
declare function getLogger(name: string): log.Logger;
interface LoggerInterface extends log.Logger {
progress(...msg: any[]): void;
}
declare function getLogger(name: string): LoggerInterface;
declare namespace getLogger {

@@ -10,3 +13,3 @@ var waitForBuffer: () => Promise<void>;

export default getLogger;
export type Logger = log.Logger;
export type Logger = LoggerInterface;
//# sourceMappingURL=node.d.ts.map

@@ -16,3 +16,4 @@ import fs from 'node:fs';

debug: 'green',
trace: 'cyan'
trace: 'cyan',
progress: 'magenta'
};

@@ -101,2 +102,13 @@ const matches = {

};
const progress = function (data) {
if (process.stdout.isTTY && this.getLevel() <= log.levels.INFO) {
const level = 'progress';
const timestampFormatter = chalk.gray(new Date().toISOString());
const levelFormatter = chalk[COLORS[level]](level.toUpperCase());
const nameFormatter = chalk.whiteBright(this.name);
const _data = data.length > 0 ? `${timestampFormatter} ${levelFormatter} ${nameFormatter}: ${data}` : '\r\x1b[K';
process.stdout.write('\u001B[?25l'); // Disable cursor in terminal
process.stdout.write(`${_data}\r`);
}
};
export default function getLogger(name) {

@@ -117,2 +129,3 @@ /**

loggers[name].methodFactory = wdioLoggerMethodFactory;
loggers[name].progress = progress;
prefix.apply(loggers[name], {

@@ -119,0 +132,0 @@ template: '%t %l %n:',

{
"name": "@wdio/logger",
"version": "8.11.0",
"version": "8.16.17",
"description": "A helper utility for logging of WebdriverIO packages",

@@ -40,3 +40,3 @@ "author": "Christian Bromann <mail@bromann.dev>",

},
"gitHead": "6fa7ae486537cbd3f6dd9e3bcc1812eb0acc6262"
"gitHead": "5bb4539c96e11a7ece83630b30c0a54903b55c0e"
}

@@ -34,1 +34,40 @@ WDIO Logger Utility

For more info see [`loglevel`](https://www.npmjs.com/package/loglevel) package on NPM.
## Custom Log Levels
This package extends the log levels available in [`loglevel`](https://www.npmjs.com/package/loglevel) by introducing a new level called `progress`.
The `progress` level is particularly useful when you need to dynamically update a specific line in the terminal. For example, it can be utilized to display the download progress of browsers or drivers.
Notably, the `progress` level is equivalent to the `info` level. Therefore, if you set the log level to `error` or `silent`, any `progress` logs will be suppressed.
It's important to mention that `progress` writes directly to `process.stdout`, and these logs won't be captured in any log files.
To ensure consistent formatting with subsequent logs while using `progress`, it's essential to clear it at the end. To do so, simply call `progress` with an empty string, which will clear the last line:
```
log.progress('')
```
### Illustrative Usage of Progress
```javascript
import logger from '@wdio/logger';
const log = logger('internal');
const totalSize = 100;
let uploadedSize = 0;
const uploadInterval = setInterval(() => {
const chunkSize = 10;
uploadedSize += chunkSize;
const data = `Progress: ${(uploadedSize * 100) / totalSize}%`;
log.progress(data);
if (uploadedSize >= totalSize) {
clearInterval(uploadInterval);
log.progress(''); // Called at the end to maintain the alignment of subsequent logs.
console.log('Upload complete.');
}
}, 100);
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc