Socket
Book a DemoInstallSign in
Socket

bunyan-debug-stream

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunyan-debug-stream

[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

3.1.1
latest
Source
npmnpm
Version published
Weekly downloads
329K
-2.22%
Maintainers
1
Weekly downloads
 
Created

What is bunyan-debug-stream?

The bunyan-debug-stream npm package is a Bunyan stream that formats Bunyan logs for output to the console, making them more readable and easier to debug. It provides various formatting options and can be integrated seamlessly with Bunyan to enhance the logging experience.

What are bunyan-debug-stream's main functionalities?

Basic Usage

This code demonstrates the basic setup of bunyan-debug-stream with a Bunyan logger. It configures the logger to use bunyan-debug-stream for formatting debug messages.

const bunyan = require('bunyan');
const debugStream = require('bunyan-debug-stream');

const log = bunyan.createLogger({
  name: 'myapp',
  streams: [{
    level: 'debug',
    type: 'raw',
    stream: debugStream({
      basepath: __dirname, // this should be the root folder of your project
      forceColor: true
    })
  }]
});

log.debug('This is a debug message');

Custom Formatting

This example shows how to customize the log format using the 'format' option. The 'short' format is used here, but other formats like 'long' and 'simple' are also available.

const bunyan = require('bunyan');
const debugStream = require('bunyan-debug-stream');

const log = bunyan.createLogger({
  name: 'myapp',
  streams: [{
    level: 'info',
    type: 'raw',
    stream: debugStream({
      basepath: __dirname,
      forceColor: true,
      format: 'short' // options include 'short', 'long', 'simple', etc.
    })
  }]
});

log.info('This is an info message');

Error Handling

This code demonstrates how bunyan-debug-stream can be used to handle and log errors. The error message is formatted and output to the console in a readable manner.

const bunyan = require('bunyan');
const debugStream = require('bunyan-debug-stream');

const log = bunyan.createLogger({
  name: 'myapp',
  streams: [{
    level: 'error',
    type: 'raw',
    stream: debugStream({
      basepath: __dirname,
      forceColor: true
    })
  }]
});

try {
  throw new Error('Something went wrong');
} catch (err) {
  log.error(err, 'An error occurred');
}

Other packages similar to bunyan-debug-stream

Keywords

bunyan

FAQs

Package last updated on 29 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.