or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

advanced-features.mdconfiguration.mdcore-logging.mdcustom-loggers.mdindex.mdscoped-loggers.mdtimers.md
tile.json

tessl/npm-signale

Hackable console logger for Node.js applications with 17 out-of-the-box logger types and advanced features including integrated timers, scoped loggers, secrets filtering, and custom pluggable loggers.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/signale@1.4.x

To install, run

npx @tessl/cli install tessl/npm-signale@1.4.0

index.mddocs/

Signale

Signale is a hackable and configurable console logger for Node.js applications that provides 17 out-of-the-box logger types with clean and beautiful output formatting. It offers advanced features including integrated timers, custom pluggable loggers, interactive and regular modes, secrets filtering, filename/date/timestamp support, scoped loggers, scaled logging levels, string interpolation, multiple configurable writable streams, and global configuration through package.json.

Package Information

  • Package Name: signale
  • Package Type: npm
  • Language: JavaScript (Node.js)
  • Installation: npm install signale

Core Imports

const signale = require('signale');

For accessing the Signale class constructor:

const { Signale } = require('signale');

Basic Usage

const signale = require('signale');

// Use built-in loggers
signale.success('Operation successful');
signale.error('Something went wrong');
signale.warn('This is a warning');
signale.info('Informational message');
signale.debug('Debug information');

// String interpolation support
signale.pending('Processing %s items...', 42);
signale.complete({
  prefix: '[task]', 
  message: 'Fix issue #59', 
  suffix: '(@username)'
});

// Handle Error objects
signale.fatal(new Error('Critical failure'));

Architecture

Signale is built around several key components:

  • Default Logger Instance: Pre-configured instance with 17 built-in logger types for immediate use
  • Signale Class: Constructor for creating custom logger instances with configurable options
  • Logger Types System: Pluggable logger type definitions with badges, colors, and labels
  • Configuration System: Global (package.json) and per-instance configuration options
  • Scoped Loggers: Hierarchical logger scoping with inheritance for organized logging
  • Timer System: Integrated timing functionality with automatic label management
  • Secrets Filtering: Built-in filtering system for sensitive information protection
  • Stream Management: Multiple configurable writable streams for flexible output control

Capabilities

Core Logging

Built-in logger types with pre-configured styling and behavior. Includes 16 default loggers for common logging scenarios.

// Default logger methods (available on signale instance)
signale.await(message);
signale.complete(message);
signale.debug(message);
signale.error(message);
signale.fatal(message);
signale.fav(message);
signale.info(message);
signale.log(message);
signale.note(message);
signale.pause(message);
signale.pending(message);
signale.star(message);
signale.start(message);
signale.success(message);
signale.wait(message);
signale.warn(message);
signale.watch(message);

// Message types supported
type LogMessage = string | string[] | {prefix?: string, message: string | string[], suffix?: string} | Error;

Core Logging

Custom Loggers

Create and configure custom logger types with personalized badges, colors, labels, and behavior.

const { Signale } = require('signale');

// Constructor options
interface SignaleOptions {
  disabled?: boolean;
  interactive?: boolean;
  logLevel?: 'info' | 'timer' | 'debug' | 'warn' | 'error';
  scope?: string | string[];
  secrets?: (string | number)[];
  stream?: NodeJS.WritableStream | NodeJS.WritableStream[];
  types?: Record<string, LoggerType>;
}

interface LoggerType {
  badge?: string;
  color?: string;
  label?: string;
  logLevel?: 'info' | 'timer' | 'debug' | 'warn' | 'error';
  stream?: NodeJS.WritableStream | NodeJS.WritableStream[];
}

const customLogger = new Signale(options);

Custom Loggers

Scoped Loggers

Create hierarchical scoped loggers with inheritance for organized logging across different modules and components.

// Create scoped logger
function scope(...name: string[]): Signale;

// Remove scope
function unscope(): void;

// Properties
readonly scopeName: string;

Scoped Loggers

Timers

Integrated timer functionality for measuring operation duration with automatic labeling and formatted output.

// Timer methods
function time(label?: string): string;
function timeEnd(label?: string): {label: string, span: number} | undefined;

Timers

Configuration & Settings

Global and instance-level configuration options for customizing logger behavior, appearance, and output format.

// Configuration method
function config(settingsObj: ConfigOptions): void;

interface ConfigOptions {
  displayScope?: boolean;
  displayBadge?: boolean;
  displayDate?: boolean;
  displayFilename?: boolean;
  displayLabel?: boolean;
  displayTimestamp?: boolean;
  underlineLabel?: boolean;
  underlineMessage?: boolean;
  underlinePrefix?: boolean;
  underlineSuffix?: boolean;
  uppercaseLabel?: boolean;
}

Configuration & Settings

Advanced Features

Interactive mode, secrets filtering, stream management, and state control for advanced logging scenarios.

// State control
function disable(): void;
function enable(): void;
function isEnabled(): boolean;

// Secrets management
function addSecrets(secrets: (string | number)[]): void;
function clearSecrets(): void;

// Properties
readonly currentOptions: SignaleOptions;
readonly date: string;
readonly timestamp: string;
readonly filename: string;
readonly packageConfiguration: object;

Advanced Features

Global Types

// Built-in logger type names
type DefaultLoggerType = 
  | 'await' | 'complete' | 'debug' | 'error' | 'fatal' | 'fav' 
  | 'info' | 'log' | 'note' | 'pause' | 'pending' | 'star' 
  | 'start' | 'success' | 'wait' | 'warn' | 'watch';

// Log levels for filtering
type LogLevel = 'info' | 'timer' | 'debug' | 'warn' | 'error';

// Scope definition
type ScopeNames = string | string[];

// Writable stream types (Node.js)
type WritableStream = NodeJS.WritableStream;
type StreamTarget = WritableStream | WritableStream[];