Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ecs-logs-js

Package Overview
Dependencies
Maintainers
102
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecs-logs-js

Logger based on winston formatting messages compatible with ecs-logs

  • 0.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-43.63%
Maintainers
102
Weekly downloads
 
Created
Source

ecs-logs-js CircleCI

Basic usage

var log = require('ecs-logs-js');

log.debug('debug message, not logged if NODE_ENV=production');
log.info('Hi there!');

Logger

The Logger type is a winston logger with preconfigured defaults to output log messages compatible with ecs-logs.

Creating and using a Logger

var ecslogs = require('ecs-logs-js');

var log = new ecslogs.Logger({
  level: 'info'
});

log.info('Hi there!');

Transport

The Transport type implements a winston log transport preconfigured to output log messages compatible with ecs-logs.

Creating and using a Transport in a winston logger

var ecslogs = require('ecs-logs-js');
var winston = require('winston');

// Instantiate an ecs-logs compatible winston logger with ecslogs.Transport
var logger = new winston.Logger({
  transports: [
    new ecslogs.Transport()
  ]
});

Formatter

The Formatter type implements a winston log formatter that produces messages compatible with ecs-logs.

The object returned when instantiating the Formatter type is callable. When called, it expects a log entry object.

When a formatter instance is called it accepts a log entry as argument and returns a JSON representation of the entry in a format compatible with ecs-logs.

Creating and using a Formatter in a winston logger

var ecslogs = require('ecs-logs-js');
var winston = require('winston');

// Instantiate an ecs-logs compatible winston logger with ecslogs.Formatter
var logger = new winston.Logger({
  transports: [
    new winston.transports.Console({
      timestamp: Date.now,
      formatter: new ecslogs.Formatter()
    })
  ]
});

Using a Formatter to serialize log entries

var ecslogs = require('ecs-logs-js');
var formatter = new ecslogs.Formatter();

// Returns a serialized log message compatible with ecs-logs.
var s = formatter({
  message: 'the log message',
  level: 'info',
  meta: {
    'User-Agent': 'node'
  }
});

Keywords

FAQs

Package last updated on 02 Feb 2019

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