@logshq.io/node
TypeScript icon, indicating that this package has built-in type declarations

1.1.11 • Public • Published

Official LogsHQ.io logger for Node.js

The official LogsHQ.io notifier for capturing Nodejs errors in Node.js and reporting them to LogsHQ.

Installation

Using npm:

npm install @logshq.io/node --save

Using yarn:

yarn add @logshq.io/node

Usage

Create a Stream and get your Stream API KEY, and use it like this:

// myLogger.js
const LogshqLogger = require('@logshq.io/node');

const logger = new LogshqLogger({
  project_id: 'SOME-PROJECT-ID',
  api_key: 'SOME-STREAM-KEY',
  environment: 'production', // optional
  hostname: 'auth-service', // optional
});

module.exports = logger

Examples

// auth.js
const { correlationId } = require('SomeModule')
const logger = require('./myLogger')

function signUp (user) {
  try {
    await authService.create(user);
    logger.debug('Signup success sending email now', {
      step: 'Step 1',
      next: 'Preparing Email',
      method: 'signUp',
      module: 'auth.js',
      correlationId
    });
    // Send Welcome Email
    logger.debug('Email sent', {
      step: 'Step 2',
      next: 'Returning OK',
      method: 'signUp',
      module: 'auth.js',
      correlationId
    });
    // Return something
    logger.info('Signup success', {
      step: 'Step 3',
      method: 'signUp',
      module: 'auth.js',
      correlationId
    });
  } catch (error) {
    logger.error('Signup failed', error, {
      method: 'signUp',
      module: 'auth.js',
      correlationId
    });
  }
}

More docs

here

/@logshq.io/node/

    Package Sidebar

    Install

    npm i @logshq.io/node

    Weekly Downloads

    3

    Version

    1.1.11

    License

    MIT

    Unpacked Size

    19 kB

    Total Files

    5

    Last publish

    Collaborators

    • logshq