@neofork/devlogr - v0.0.1
    Preparing search index...

    Class Logger

    Main DevLogr Logger class providing structured logging with visual enhancements.

    The Logger class is the heart of DevLogr, offering:

    • Multiple log levels (error, warning, info, debug, trace, success)
    • Animated spinners with automatic fallbacks
    • Task management integration with listr2
    • JSON output mode for machine parsing
    • Terminal-aware formatting with color and emoji support
    • Zero-configuration setup with environment variable overrides
    import { createLogger } from '@neofork/devlogr';

    const log = createLogger('my-app');

    log.info('Application starting...');
    log.success('Setup complete!');
    log.error('Something went wrong', error);
    const log = createLogger('deploy');

    log.startSpinner('Deploying application...');
    // ... do work ...
    log.succeedSpinner('Deployment successful!');
    const log = createLogger('build');

    await log.runTasks('Build Process', [
    { title: 'Compile TypeScript', task: () => compileTS() },
    { title: 'Bundle Assets', task: () => bundleAssets() },
    { title: 'Generate Documentation', task: () => generateDocs() }
    ]);
    Index

    Constructors

    Methods

    • Set the global log level for all Logger instances. Overrides environment variable configuration.

      Parameters

      • level: LogLevel

        The minimum log level to display

      Returns void

    • Reset the global log level to use environment-based configuration.

      Returns void

    • Log an informational message.

      Parameters

      • message: string

        The main message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log an error message with optional error object.

      Parameters

      • message: string

        The error message to log

      • Optionalerror: unknown

        Optional error object or additional data

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log a warning message.

      Parameters

      • message: string

        The warning message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Alias for warning() method.

      Parameters

      • message: string

        The warning message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log a debug message (only shown when debug level is enabled).

      Parameters

      • message: string

        The debug message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log a trace message (only shown when trace level is enabled).

      Parameters

      • message: string

        The trace message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log a success message with positive visual styling.

      Parameters

      • message: string

        The success message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log a title message with prominent visual styling.

      Parameters

      • message: string

        The title message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log a task message indicating work in progress.

      Parameters

      • message: string

        The task message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Log a plain message without any visual styling or symbols.

      Parameters

      • message: string

        The plain message to log

      • ...args: unknown[]

        Additional arguments to include in the log output

      Returns void

    • Start an animated spinner with optional text and styling options.

      Spinners provide visual feedback for long-running operations. They automatically fall back to simple task messages in JSON mode or when the terminal doesn't support ANSI escape sequences.

      Parameters

      • Optionaltext: string

        Text to display alongside the spinner (defaults to "Processing...")

      • Optionaloptions: Omit<SpinnerOptions, "text">

        Optional spinner configuration (color, style, etc.)

      Returns void

      log.startSpinner('Installing dependencies...');
      // ... perform work ...
      log.succeedSpinner('Dependencies installed!');
      log.startSpinner('Deploying...', { color: 'yellow' });
      
    • Update the text of the currently active spinner.

      Parameters

      • text: string

        New text to display with the spinner

      Returns void

    • Stop the current spinner without displaying any completion message.

      Returns void

    • Complete the current spinner with a specific completion type and message.

      Parameters

      • type: "error" | "info" | "success" | "warning"

        Type of completion (success, error, warning, info)

      • Optionaltext: string

        Optional completion message (uses default if not provided)

      Returns void

    • Complete the current spinner with a success message.

      Parameters

      • Optionaltext: string

        Optional success message

      Returns void

    • Complete the current spinner with an error message.

      Parameters

      • Optionaltext: string

        Optional error message

      Returns void

    • Complete the current spinner with a warning message.

      Parameters

      • Optionaltext: string

        Optional warning message

      Returns void

    • Complete the current spinner with an info message.

      Parameters

      • Optionaltext: string

        Optional info message

      Returns void

    • Complete the current spinner with a success message (short alias).

      Parameters

      • Optionaltext: string

        Optional success message

      Returns void

      log.startSpinner('Uploading files...');
      log.succeedSpinner('Upload complete!');
    • Complete the current spinner with an error message (short alias).

      Parameters

      • Optionaltext: string

        Optional error message

      Returns void

    • Complete the current spinner with a warning message (short alias).

      Parameters

      • Optionaltext: string

        Optional warning message

      Returns void

    • Complete the current spinner with an info message (short alias).

      Parameters

      • Optionaltext: string

        Optional info message

      Returns void

    • Execute a listr2 task list with proper logger integration

      Type Parameters

      • T = any

      Parameters

      • title: string
      • tasks: ListrTask<T, any, any>[]
      • Optionaloptions: {
            concurrent?: boolean;
            exitOnError?: boolean;
            context?: T;
            rendererOptions?: any;
        }

      Returns Promise<T>

    • Create a task list with the logger's prefix integration

      Type Parameters

      • T = any

      Parameters

      • tasks: ListrTask<T, any, any>[]
      • Optionaloptions: { concurrent?: boolean; exitOnError?: boolean; context?: T }

      Returns Listr<T, typeof DevLogrRenderer>

    • Execute concurrent tasks with proper logging

      Type Parameters

      • T = any

      Parameters

      • title: string
      • tasks: ListrTask<T, any, any>[]
      • Optionalcontext: T

      Returns Promise<T>

    • Execute sequential tasks with proper logging

      Type Parameters

      • T = any

      Parameters

      • title: string
      • tasks: ListrTask<T, any, any>[]
      • Optionalcontext: T

      Returns Promise<T>

    • Parameters

      • Optionaltitle: string

      Returns void