Console
Wraps console operations in Effect.
The Console service exposes common console methods such as logging, warnings, errors, groups, counters, tables, and timers. Because console access goes through a service, programs can use custom console implementations in tests or other environments. This module also includes scoped helpers that close console groups or timers automatically.
Accessors
Signature
declare function assert(condition: boolean, ...args: readonly Array<any>): Effect<void>Runs the current console service's clear operation.
When to use
Use to request that the active console implementation clear its visible output.
Gotchas
The clearing behavior depends on the active console implementation and host environment.
Signature
declare const clear: Effect.Effect<void>;Logs and increments the counter associated with label, using the console's default counter when no label is provided.
Signature
declare function count(label?: string): Effect<void>;countReset
Resets the counter associated with the specified label back to zero.
Signature
declare function countReset(label?: string): Effect<void>;Writes a debug message through the current Console service.
Details
The arguments are passed to the service's debug method when the returned Effect is executed. Any filtering behavior depends on the active console implementation.
Signature
declare function debug(...args: readonly Array<any>): Effect<void>Displays an interactive list of the properties of the specified object, optionally using console-specific inspection options for debugging complex data structures.
Signature
declare function dir(item: any, options?: any): Effect<void>;Displays an interactive tree of descendant XML or HTML elements, which is particularly useful for inspecting DOM elements in browser environments.
Signature
declare function dirxml(...args: readonly Array<any>): Effect<void>Writes an error-level message to the console, typically displayed with error styling by the active console implementation.
Signature
declare function error(...args: readonly Array<any>): Effect<void>Creates a scoped console group, optionally collapsed and labeled, and closes it automatically when the Effect scope is finalized.
Signature
declare function group(options?: {
collapsed?: boolean;
label?: string;
}): Effect<void, never, Scope>;Writes an informational message to the console, typically displayed with info styling by the active console implementation.
Signature
declare function info(...args: readonly Array<any>): Effect<void>Logs a general-purpose message to the console.
Signature
declare function log(...args: readonly Array<any>): Effect<void>Displays tabular data as a formatted table in the console, optionally limited to selected properties.
Signature
declare function table(tabularData: any, properties?: readonly Array<string>): Effect<void>Starts a scoped timer for label and automatically ends it when the Effect scope is finalized.
Signature
declare function time(label?: string): Effect<void, never, Scope>;Logs the elapsed time for an existing timer without stopping it, allowing progress reports for long-running operations.
Signature
declare function timeLog(label?: string, ...args: readonly Array<any>): Effect<void>Writes the current stack trace to the console to show how the current point in the code was reached.
Signature
declare function trace(...args: readonly Array<any>): Effect<void>Writes a warning-level message to the console, typically displayed with warning styling by the active console implementation.
Signature
declare function warn(...args: readonly Array<any>): Effect<void>Runs an Effect inside an optionally labeled or collapsed console group, starting the group before execution and ending it after the Effect completes.
Signature
declare const withGroup: (options?: {
readonly collapsed?: boolean;
readonly label?: string;
}) => <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R> & <A, E, R>(self: Effect<A, E, R>, options?: {
readonly collapsed?: boolean;
readonly label?: string;
}) => Effect<A, E, R>Runs an Effect with a console timer, starting the timer before execution and ending it after the Effect completes.
Signature
declare const withTime: (label?: string) => <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R> & <A, E, R>(self: Effect<A, E, R>, label?: string) => Effect<A, E, R>Constructors
consoleWith
Creates an Effect that provides access to the current console service and lets you perform operations with it within an Effect context.
Signature
declare function consoleWith<A, E, R>(f: (console: Console) => Effect<A, E, R>): Effect<A, E, R>;Services
Context reference for the current console service in the Effect system, allowing access to the active console implementation from within the Effect context.
When to use
Use when you need an effect to run against a provided console implementation, such as tests or alternate runtimes, rather than the default console.
Details
When no override is provided, the reference resolves to globalThis.console.
See
consoleWithfor using the current console service inside an effect
Signature
declare const Console: Reference<Console>;Represents a console interface for logging, debugging, timing, and grouping output.
Signature
interface Console {
assert(condition: boolean, ...args: readonly Array<any>): void;
clear(): void;
count(label?: string): void;
countReset(label?: string): void;
debug(...args: readonly Array<any>): void;
dir(item: any, options?: any): void;
dirxml(...args: readonly Array<any>): void;
error(...args: readonly Array<any>): void;
group(...args: readonly Array<any>): void;
groupCollapsed(...args: readonly Array<any>): void;
groupEnd(): void;
info(...args: readonly Array<any>): void;
log(...args: readonly Array<any>): void;
table(tabularData: any, properties?: readonly Array<string>): void;
time(label?: string): void;
timeEnd(label?: string): void;
timeLog(label?: string, ...args: readonly Array<any>): void;
trace(...args: readonly Array<any>): void;
warn(...args: readonly Array<any>): void;
}
Writes the supplied assertion message to the console as an error when
conditionis false; whenconditionis true, no console output is produced.