Tailed
  • Tailed
  • How it works
  • Zero-Install Web Tailer
    • Getting Started
    • Limitations
  • Command Line Tool
    • Installation
    • Reference
  • Client Libraries
    • .NET
    • Node JS
  • Colorization
    • Standard Rules
    • Custom Rules
  • Roadmap
  • GitHub Repositories
Powered by GitBook
On this page
  • Setup
  • Basic Usage
  • Default Colorization
  • Customization Options
  1. Client Libraries

Node JS

How to instrument Tailed from Node with just three lines of code.

Setup

Install the @tailedapp/nodejs-lib npm package:

npm i @tailedapp/nodejs-lib

Basic Usage

You will need to create a new ConsoleSession and then start it:

// Two of the magic lines of code..
const session = new ConsoleSession();
await session.Start();

console.log('This will be streamed to tailed.live');

// The last one!
session.Stop();

console.log('This will not be streamed to tailed.live');

Choose the right point at which to start the ConsoleSession. For example, if you're asking the user for credentials or a connection string, you'll want to start the session after that point so you don't stream those details to everyone viewing the session.

Any logging framework that has a console output can be used together with the above configuration code.

Default Colorization

The following default color rules apply:

  • console.info will write content with a green color;

  • console.warn will write content with a yellow color;

  • console.error will write content with a red color;

  • stderr.write will write content with a red color.

  • In all other cases, the colors will be the defaults.

Customization Options

The constructor on the ConsoleSession allows you to specify a custom hostname to use in the session URL (instead of tailed.live).

Previous.NETNextStandard Rules

Last updated 1 year ago

Further colorization can be applied using NPM packages such as .

chalk