New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@janiscommerce/log

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@janiscommerce/log

A package for creating logs in Firehose

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
414
increased by17.28%
Maintainers
1
Weekly downloads
 
Created
Source

log

Build Status Coverage Status

A package for creating logs in Firehose

Installation

npm install @janiscommerce/log

Configuration

ENV variables

JANIS_SERVICE_NAME (required): The name of the service that will create the log.
JANIS_ENV (required): The name stage that will used as suffix for janis-trace-service bucket.

API

add(clientCode, log)

Parameters: clientCode [String], log [Object]
Puts the recieved log into the janis-trace-firehose

Log structure

The log [Object] parameter have the following structure:

  • id [String] (optional): The ID of the log in UUID V4 format. Default will be auto-generated.
  • service [String] (optional): The service name, if this field not exists, will be obtained from the ENV (JANIS_SERVICE_NAME)
  • type [String] (required): The log type
  • entity [String] (required): The name of the entity that is creating the log
  • entityId [String] (optional): The ID of the entity that is creating the log
  • message [String] (optional): A general message about the log
  • log [Object|Array] (optional): This property is a JSON that includes all the technical data about your log.

Log example

{
  id: '0acefd5e-cb90-4531-b27a-e4d236f07539',
  type: 'new',
  entity: 'api',
  entity_id: 'log',
  service: 'trace',
  message: '[GET] Request from 12.345.67.89 to /log',
  date_created: 1559103066,
  log: {
    verb: 'GET',
    headers: {
      'x-forwarded-for': '12.345.67.89',
      'x-forwarded-proto': 'https',
      'x-forwarded-port': '443'
    },
    responseHttpCode: 200
  }
}

on(event, callback)

Parameters: event [String], callback [Function] Calls a callback when the specified event is emitted.

Errors

The errors are informed with a LogError.
This object has a code that can be useful for a correct error handling.
The codes are the following:

CodeDescription
1Invalid log
2Firehose Error
3Unknown stage name

In case of error while creating your log into S3, this package will emit an event called create-error, you can handle it using the on() method.

Usage

const Log = require('@janiscommerce/log');

Log.add('some-client', {
	type: 1,
	entity: 'api',
	entityId: 'product',
	message: '[GET] Request from 0.0.0.0 of custom_data'
	// ...
});

Log.on('create-error', (log, err) => {
	console.error(`An error occurred while creating the log ${err.message}`);
});

FAQs

Package last updated on 14 Feb 2020

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc