About

May 29, 2022

What is it?

It is an extendable isomorphic log sending library written in TypeScript for JavaScript applications in Node.js and browsers.

It can be extended with custom strategy (“when to send logs”) and service (“where to send logs”).

It does not restrict you with conventions, for example, existence of logSeverity, ErrorId, or message fields in a log.

It supports any format of logs via a custom serializer.

How it works

  1. You call logger.log(payload) with any object shape.
  2. LogStore buffers logs and can apply transformations (for example rapid-fire grouping).
  3. A strategy listens for new logs and emits send when it is time to flush.
  4. The configured service serializes the batch and posts it (HTTP via native fetch for remote services).

See Getting started for installation and Service / Strategy for built-in plugins.

Features

  • Works in browsers and Node.js
  • Sends single logs or bundles to external endpoints
  • Log sending strategies:
    1. Interval — throttle flushes while logs arrive (default 15s)
    2. On request — flush only when you call sendAllLogs()
    3. On bundle size — flush when the buffer reaches N logs (default 100)
    4. Instant — one log in, one send out
  • Groups duplicate logs in a time window (rapid-fire grouping)
  • Handles circular references in log objects (fast-safe-stringify)
  • Custom per-log serialization
  • Built-in remote endpoints: Sumo Logic, Loggly, Elasticsearch, plus console debugging

Runnable examples: advanced-logger example/.

Runtime environment support

The package ships dual ESM (dist/index.mjs) and CommonJS (dist/index.cjs) builds, type declarations (dist/index.d.ts), and a browser IIFE global (dist/index.global.js). It has no runtime npm dependencies (lodash throttle and safe stringify are bundled in).

  • Node.js18+ for global fetch; developed and tested on Node.js 24+ (see library .mise.toml)
  • Browser — modern browsers with native fetch and ES2015+; consumers on older targets should transpile and polyfill

Links

NPM package

GitHub repository

Feature branch build npm version install size

Quality checks Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Maintainability Rating Reliability Rating Security Rating Technical Debt Vulnerabilities

Conventional Commits

FOSSA Status