import pino from "pino"; import { LogLine } from "./v3/types/public/logs.js"; export interface LoggerOptions { pretty?: boolean; level?: pino.Level; destination?: pino.DestinationStream; usePino?: boolean; } /** * Creates a configured Pino logger instance */ export declare function createLogger(options?: LoggerOptions): pino.Logger; /** * StagehandLogger class that wraps Pino for our specific needs * * LOGGING PRECEDENCE: * * Test environments: * - External logger provided -> external logger only. * - No external logger -> console fallback only (Pino disabled). * * Non-test environments: * - usePino === true -> emit via Pino and also call the external logger when present. * - usePino === false -> disable Pino; use the external logger when present, otherwise console fallback. * - usePino === undefined -> prefer the external logger when present; otherwise use Pino. * * SHARED PINO OPTIMIZATION: * We maintain a single shared Pino instance when `usePino` is enabled. * This prevents spawning a new worker thread for every Stagehand instance * (which happens when `pino-pretty` transport is used), eliminating the * memory/RSS growth observed when many Stagehand objects are created and * disposed within the same process (e.g. a request-per-instance API). */ export declare class StagehandLogger { /** * Shared Pino logger instance across all StagehandLogger instances. * First instance to enable Pino creates it, subsequent instances reuse it. */ private static sharedPinoLogger; private logger?; private verbose; private externalLogger?; private usePino; private isTest; constructor(options?: LoggerOptions, externalLogger?: (logLine: LogLine) => void); /** * Set the verbosity level */ setVerbosity(level: 0 | 1 | 2): void; /** * Log a message using our LogLine format */ log(logLine: LogLine): void; /** * Helper to format auxiliary data for structured logging */ private formatAuxiliaryData; /** * Convenience methods for different log levels */ error(message: string, data?: Record): void; warn(message: string, data?: Record): void; info(message: string, data?: Record): void; debug(message: string, data?: Record): void; /** * Convert a plain object to our auxiliary format */ private convertToAuxiliary; }