1.1.11 • Published 1 year ago

@logshq.io/node v1.1.11

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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

1.1.9

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago