SkillAgentSearch skills...

Cabin

:evergreen_tree: Cabin is the best self-hosted JavaScript and Node.js logging service. Made for @forwardemail.

Install / Use

/learn @cabinjs/Cabin

README

<h1 align="center"> <a href="http://cabinjs.com"><img src="https://d1i8ikybhfrv4r.cloudfront.net/cabin-animated.gif" alt="cabin" /></a> </h1> <div align="center"> <a href="https://github.com/cabinjs/cabin/actions/workflows/ci.yml"><img src="https://github.com/cabinjs/cabin/actions/workflows/ci.yml/badge.svg" alt="build status" /></a> <a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="code style" /></a> <a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="styled with prettier" /></a> <a href="https://lass.js.org"><img src="https://img.shields.io/badge/made_with-lass-95CC28.svg" alt="made with lass" /></a> <a href="LICENSE"><img src="https://img.shields.io/github/license/cabinjs/cabin.svg" alt="license" /></a> <a href="https://npm.im/cabin"><img src="https://img.shields.io/npm/dt/cabin.svg" alt="npm downloads" /></a> </div> <br /> <div align="center"> Cabin is the best self-hosted <a href="https://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a> and <a href="https://nodejs.org" target="_blank">Node.js</a> <a href="https://en.wikipedia.org/wiki/Logging_as_a_service" target="_blank">logging service</a>. <br /> <small>Supports Node v18+, Browser Environments, <a href="https://expressjs.com" target="_blank">Express</a>, <a href="https://koajs.com" target="_blank">Koa</a>, and <a href="https://lad.js.org" target="_blank">Lad</a></small> </div> <hr /> <div align="center"> Cabin is compatible with <a href="https://sentry.io" target="_blank">Sentry</a>, <a href="https://airbrake.io/" target="_blank">Airbrake</a>, <a href="https://papertrailapp.com/" target="_blank">Papertrail</a>, <a href="https://www.loggly.com/" target="_blank">Loggly</a>, and <a href="https://www.bugsnag.com/" target="_blank">Bugsnag</a>. </div> <hr />

Table of Contents

Foreword

Please defer to Axe's Foreword for more insight.

Cabin is a layer on top of Axe that provides automatic logging for route middleware requests and errors.

Quick Start

npm install express axe cabin signale
const express = require('express');
const Axe = require('axe');
const Cabin = require('cabin');
const app = express();
const { Signale } = require('signale');

// initialize a new instance of Axe (see below TODO's that appeal to you)
const logger = new Axe({
  logger: new Signale()
});

// TODO: if you want to send logs to an HTTP endpoint then follow this guide:
// https://github.com/cabinjs/axe/#send-logs-to-http-endpoint

// TODO: if you want to send logs to Slack then follow this guide:
// https://github.com/cabinjs/axe/#send-logs-to-slack

// TODO: if you want to send logs to Sentry then follow this guide:
// https://github.com/cabinjs/axe/#send-logs-to-sentry

// TODO: if you want to send logs to Datadog then follow this guide:
// https://github.com/cabinjs/axe/#send-logs-to-datadog

// TODO: if you want to send logs to Papertrail then follow this guide:
// https://github.com/cabinjs/axe/#send-logs-to-papertrail

// TODO: if you want to suppress specific log metadata then follow this guide:
// https://github.com/cabinjs/axe/#suppress-logger-data

// initialize a new instance of Cabin with an Axe logger instance
const cabin = new Cabin({ logger });

//
// initialize route logging middleware
//
// NOTE: this will automatically log route middleware requests and errors
//
app.use(cabin.middleware);

app.get('/', (req, res, next) => res.send('OK'));

// start the server
app.listen(3000);
curl http://localhost:3000

Features

Security, Privacy, and Business Focused

Cabin will automatically detect and mask the following list of extremely sensitive types of data in your logs:

  • [1600+ Sensitive Field Names][sensitive-fields]
  • Credit Card Numbers<sup>*</sup>
  • [BasicAuth Headers][basicauth-headers]
  • Social Security Numbers
  • [JSON Web Tokens ("JWT")][jwt-tokens]
  • API Keys, CSRF Tokens, and Stripe Tokens
  • Passwords, Salts, and Hashes
  • Bank Account Numbers and Bank Routing Numbers

<small><sup>*</sup>Credit card numbers from the following providers are automatically detected and masked: Visa, Mastercard, American Express, Diners Club, Discover, JCB, UnionPay, Maestro, Mir, Elo, Hiper, Hipercard</small>

Reduce Disk Storage Costs

Reduce your disk storage costs through Cabin's automatic conversion of Streams, Buffers, and ArrayBuffers to simplified, descriptive-only objects that otherwise would be unreadable (and obviously pollute your log files and disk storage).

Before:

{
  "request": {
    "body": {
      "file": {
        "type": "Buffer",
        "data": [
          76,
          111,
          114,
          101,
          109,
          32,
          105,
          112,
          115,
          117,
          109,
          32,
          100,
          111,
          108,
          111,
          114,
          32,
          115,
          105,
          116,
          '...'
        ]
      }
    }
  }
}

After

{
  "request": {
    "body": {
      "file": {
        "type": "Buffer",
        "byteLength": 2787
      }
    }
  }
}

Cross-Platform and Cross-Browser Compatible

Cabin works with the most popular Node.js HTTP frameworks (e.g. [Express][] and [Koa][]), request body handling packages (e.g. [multer][] and [body-parser][]), and the [passport][] authentication framework.

It supports Node v18+ and modern browsers out of the box (its browser-ready bundle is only 20 KB).

npx browserslist
and_chr 107
and_ff 106
and_qq 13.1
and_uc 13.4
android 107
chrome 107
chrome 106
chrome 105
edge 107
edge 106
edge 105
firefox 106
firefox 105
firefox 102
ios_saf 16.1
ios_saf 16.0
ios_saf 15.6
ios_saf 15.5
ios_saf 14.5-14.8
kaios 2.5
op_mini all
op_mob 64
opera 91
opera 90
safari 16.1
safari 16.0
safari 15.6
samsung 18.0
samsung 17.0

Send Logs to an HTTP endpoint

See the Quick Start section above and our guide at https://github.com/cabinjs/axe/#send-logs-to-http-endpoint.

Send Logs to Slack

See the Quick Start section above and our guide at https://github.com/cabinjs/axe/#send-logs-to-slack.

Send Logs to Sentry

See the Quick Start section above and our guide at https://github.com/cabinjs/axe/#send-logs-to-sentry.

Send Logs to Datadog

See the Quick Start section above and our guide at https://github.com/cabinjs/axe/#send-logs-to-datadog.

Send Logs to Papertrail

See the Quick Start section above and our guide at https://github.com/cabinjs/axe/#send-logs-to-papertrail.

Suppress Logger Data

See the Quick Start section above and our guide at https://github.com/cabinjs/axe/#suppress-logger-data.

Install

Note that as of v11.0.0 Cabin requires a peer dependency of [Axe][] to be installed.

[npm][]:

npm install cabin axe

Usage

Logging

const Cabin = require('cabin');
const cabin = new Cabin({
  // ... see the Quick Start and Options sections
});

cabin.info('hello world');
cabin.error(new Error('oops!'));

Route Logging Middleware

app.use(cabin.middleware);

See either the Node or Browser instructions below for further route middleware usage and proper setup.

Node

The examples below show how to use Cabin in combination with [Axe][], [Signale][] (instead of console), and how to add an accurate X-Response-Time response time metric to your logs and response headers automatically.

Koa

  1. Install required and recommended dependencies:

    npm install koa cabin signale request-received koa-better-response-time koa-better-request-id
    
  2. Implement the example code below (also found here):

    const Koa = require('koa');
    const Cabin = require('cabin');
    const Router = require('koa-router');
    const requestReceived = require('request-received');
    const responseTime = require('koa-better-response-time');
    const requestId = require('koa-better-request-id');
    const { Signale } = require('signale');
    
    const app = new Koa();
    const router = new Router();
    const cabin = new Cabin({
      logger: new Signale()
    });
    
    // adds request received hrtime and date symbols to request object
    // (which is used by Cabin internally to add `request.timestamp` to logs
    app.use(requestReceived);
    
    // adds `X-Response-Time` header to responses
    app.use(responseTime());
    
    // adds or re-uses `X-Request-Id` header
    app.use(requestId());
    
    // use the cabin middleware (adds request-based logging and helpers)
    app.use(cabin.middleware);
    
    // add your user/session management middleware here (e.g. passport)
    // ...
    
    // an
    
View on GitHub
GitHub Stars894
CategoryProduct
Updated5d ago
Forks43

Languages

JavaScript

Security Score

100/100

Audited on Mar 27, 2026

No findings