or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

browser.mdconfiguration.mdcore-logging.mdindex.mdmasking.md
tile.json

tessl/npm-wdio--logger

A helper utility for logging of WebdriverIO packages with enhanced features like progress logging and masking patterns for secure logging

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@wdio/logger@9.18.x

To install, run

npx @tessl/cli install tessl/npm-wdio--logger@9.18.0

index.mddocs/

@wdio/logger

@wdio/logger is a comprehensive logging utility specifically designed for WebdriverIO packages and Node.js applications. Built on top of the loglevel package, it extends standard logging capabilities with a custom 'progress' level for dynamic terminal updates, masking patterns for secure logging of sensitive information, and colorized output using chalk. The library offers scoped logger instances, supports both browser and Node.js environments through multiple export formats, and includes advanced features like regex-based masking patterns that can obfuscate credentials and secrets from logs.

Package Information

  • Package Name: @wdio/logger
  • Package Type: npm
  • Language: TypeScript/JavaScript
  • Installation: npm install @wdio/logger

Core Imports

import logger from '@wdio/logger';
import { SENSITIVE_DATA_REPLACER, parseMaskingPatterns, mask } from '@wdio/logger';
import type { Logger } from '@wdio/logger';

For CommonJS:

const logger = require('@wdio/logger');
const { SENSITIVE_DATA_REPLACER, parseMaskingPatterns, mask } = require('@wdio/logger');

Basic Usage

import logger from '@wdio/logger';

// Create a logger instance for your component
const log = logger('myPackage');

// Use standard log levels
log.info('Application started');
log.warn('This is a warning');
log.error('An error occurred');

// Use the special progress logging for dynamic updates
log.progress('Processing... 50%');
log.progress('Processing... 100%');
log.progress(''); // Clear the progress line

// Set log level for a specific logger
logger.setLevel('myPackage', 'debug');

// Configure masking patterns for sensitive data
logger.setMaskingPatterns('/--key=([^ ]*)/i,/--secret=([^ ]*)/i');

Architecture

@wdio/logger is built around several key components:

  • Logger Factory: Main getLogger() function that creates or retrieves logger instances
  • Environment Support: Dual implementation for Node.js (full features) and browser (console adapter)
  • Masking System: Regex-based pattern matching for obfuscating sensitive data in logs
  • Progress Logging: Special log level for dynamic terminal updates with cursor manipulation
  • File Logging: Optional file output with environment variable configuration
  • Log Level Management: Per-logger and global log level configuration

Capabilities

Core Logging

Standard logging functionality with enhanced WebdriverIO-specific features including colorized output, prefixed messages, and file logging support.

function getLogger(name: string): Logger;

interface Logger {
  trace(...args: any[]): void;
  debug(...args: any[]): void;
  info(...args: any[]): void;
  warn(...args: any[]): void;
  error(...args: any[]): void;
  progress(...msg: string[]): void;
  setLevel(level: LogLevelDesc): void;
  getLevel(): LogLevelNumbers;
  maskingPatterns: RegExp[] | undefined;
}

Core Logging

Configuration Management

Global configuration for log levels, masking patterns, and file output with support for per-logger customization.

function setLogLevelsConfig(
  logLevels?: Record<string, LogLevelDesc>, 
  wdioLogLevel?: LogLevelDesc
): void;

function setMaskingPatterns(
  pattern: string | Record<string, string>
): void;

function setLevel(name: string, level: LogLevelDesc): void;

Configuration Management

Masking Utilities

Security-focused utilities for parsing masking patterns and applying masks to sensitive data in log messages.

function parseMaskingPatterns(
  maskingRegexString: string | undefined
): RegExp[] | undefined;

function mask(
  text: string, 
  maskingPatterns: RegExp[] | undefined
): string;

const SENSITIVE_DATA_REPLACER: "**MASKED**";

Masking Utilities

Browser Support

Browser-compatible logger implementation that adapts console methods for consistent API across environments.

function getLogger(component: string): Console;

Browser Support

Types

type LogLevelDesc = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
type LogLevelNumbers = 0 | 1 | 2 | 3 | 4 | 5;

interface Logger {
  trace(...args: any[]): void;
  debug(...args: any[]): void;
  info(...args: any[]): void;
  warn(...args: any[]): void;
  error(...args: any[]): void;
  progress(...msg: string[]): void;
  setLevel(level: LogLevelDesc): void;
  getLevel(): LogLevelNumbers;
  maskingPatterns: RegExp[] | undefined;
}

// Static methods available on the main logger function
interface LoggerFactory {
  (name: string): Logger;
  waitForBuffer(): Promise<void>;
  setLevel(name: string, level: LogLevelDesc): void;
  clearLogger(): void;
  setLogLevelsConfig(logLevels?: Record<string, LogLevelDesc>, wdioLogLevel?: LogLevelDesc): void;
  setMaskingPatterns(pattern: string | Record<string, string>): void;
}