Lib

Log Module Reference

Documentation / log

LogOptions

Defined in: log.ts:75

Properties

style?

string | string[]

CSS style string or array of CSS strings for browser console styling

log.ts:77

color?

| "reset" | "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "brightRed" | "brightGreen" | "brightYellow" | "brightBlue" | "brightMagenta" | "brightCyan" | "brightWhite" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray"

Optional color name or code for terminal environments

log.ts:79

hideInProduction?

boolean

If true, hides log in production (auto-detects by hostname if undefined)

log.ts:81

startSpinner?

boolean

Start a spinner (for CLI tools, optional)

log.ts:83

stopSpinner?

boolean

Stop a spinner (for CLI tools, optional)

log.ts:85


colors

const colors: object;

Defined in: log.ts:89

ANSI escape codes for terminal colors when running in Node.js

Type declaration

reset

string

"\x1b[0m"

log.ts:90

black

string

"\x1b[30m"

log.ts:91

red

string

"\x1b[31m"

log.ts:92

green

string

"\x1b[32m"

log.ts:93

yellow

string

"\x1b[33m"

log.ts:94

blue

string

"\x1b[34m"

log.ts:95

magenta

string

"\x1b[35m"

log.ts:96

cyan

string

"\x1b[36m"

log.ts:97

white

string

"\x1b[37m"

log.ts:98

gray

string

"\x1b[90m"

log.ts:99

brightRed

string

"\x1b[91m"

Bright variants

log.ts:101

brightGreen

string

"\x1b[92m"

log.ts:102

brightYellow

string

"\x1b[93m"

log.ts:103

brightBlue

string

"\x1b[94m"

log.ts:104

brightMagenta

string

"\x1b[95m"

log.ts:105

brightCyan

string

"\x1b[96m"

log.ts:106

brightWhite

string

"\x1b[97m"

log.ts:107

bgRed

string

"\x1b[41m"

Background colors (optional)

log.ts:109

bgGreen

string

"\x1b[42m"

log.ts:110

bgYellow

string

"\x1b[43m"

log.ts:111

bgBlue

string

"\x1b[44m"

log.ts:112

bgMagenta

string

"\x1b[45m"

log.ts:113

bgCyan

string

"\x1b[46m"

log.ts:114

bgWhite

string

"\x1b[47m"

log.ts:115

bgGray

string

"\x1b[100m"

log.ts:116


log()

function log(message: string, options: LogOptions): boolean;

Defined in: log.ts:13

Colorized Log With JSON Structure

Debug log Logs messages to the console with custom styling, prints JSON with description of structure layout, and showing debug output in development only.

Parameters

message

string

""

The message to log. If an object is provided, it will be stringified.

options

LogOptions

{}

Returns

boolean


printJSONStructure()

function printJSONStructure(obj: any, indent: number): string;

Defined in: log.ts:157

Creates a colored visualization of a JSON object's structure Shows the shape and types of the data rather than actual values Recursively processes nested objects and arrays

Parameters

obj

any

undefined

indent

number

0

Returns

string


showAlert()

function showAlert(msg: any): void;

Defined in: log.ts:228

Shows message in a modal overlay with scrollable message stack and is easier to dismiss unlike alert() which blocks window. Creates a semi-transparent overlay with a white box containing the message.

Parameters

msg

any

The message to display

Returns

void


setupDevTools()

function setupDevTools(): void;

Defined in: log.ts:266

Sets up development tools for debugging API requests Adds a keyboard shortcut (Ctrl+I) that shows a modal with request history Each request entry shows:

  • Request path
  • Request details
  • Response data
  • Timestamp

Returns

void


showSpinnerInTerminal()

function showSpinnerInTerminal(text: any): (success: string) => void;

Defined in: log.ts:297

Displays an animated spinner in the terminal with the provided text. The spinner animates in-place until the returned function is called, which stops the spinner and prints a success message.

Parameters

text

any

The text to display next to the spinner animation.

Returns

Stop function with optional message.

(success: string): void;

Parameters

success

string

"✔ Done!"

Returns

void

Example

const stopSpinner = showSpinnerInTerminal('Downloading...');
setTimeout(() => {
   stopSpinner('Success!');
}, 2000);