Skip to main content

Logger

A console-compatible logger interface used by the Adaline client and Monitor for internal diagnostic output.

Import

import type { Logger } from '@adaline/client';

Definition

interface Logger {
  debug(message: string, ...args: unknown[]): void;
  info(message: string, ...args: unknown[]): void;
  warn(message: string, ...args: unknown[]): void;
  error(message: string, ...args: unknown[]): void;
}

Methods

MethodDescription
debug(message, ...args)Verbose diagnostic information, useful during development.
info(message, ...args)General operational messages (e.g., flush completed, deployment fetched).
warn(message, ...args)Potential issues that don’t prevent operation (e.g., retry attempts).
error(message, ...args)Failures that need attention (e.g., API errors, flush failures).
Any object that implements these four methods is a valid Logger. This includes the built-in console object as well as popular logging libraries like Winston, Pino, and Bunyan.

Usage

Using debug: true

The simplest way to enable logging is the debug shortcut, which uses console as the logger:
import { Adaline } from '@adaline/client';

const adaline = new Adaline({ debug: true });

Passing console directly

Equivalent to debug: true:
import { Adaline } from '@adaline/client';

const adaline = new Adaline({ logger: console });

Custom logger

Provide any object that satisfies the Logger interface:
import { Adaline } from '@adaline/client';
import type { Logger } from '@adaline/client';

const logger: Logger = {
  debug: (msg, ...args) => console.debug(`[adaline] ${msg}`, ...args),
  info:  (msg, ...args) => console.info(`[adaline] ${msg}`, ...args),
  warn:  (msg, ...args) => console.warn(`[adaline] ${msg}`, ...args),
  error: (msg, ...args) => console.error(`[adaline] ${msg}`, ...args),
};

const adaline = new Adaline({ logger });

With a logging library

Works with any library that exposes the standard log-level methods:
import { Adaline } from '@adaline/client';
import pino from 'pino';

const logger = pino({ level: 'debug' });
const adaline = new Adaline({ logger });

See Also

  • Adaline — accepts logger and debug in its constructor options