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

fwsp-logger

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fwsp-logger

Provides logging via pino, and transport to elasticsearch

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27
decreased by-48.08%
Maintainers
1
Weekly downloads
 
Created
Source

Logger Build Status

Synopsis

Provides a pino logger that ships its logs to Elasticsearch via pino-elasticsearch.

First, run npm install -g pino-elasticsearch

In Hydra-Express service entry-point script:

let logger = config.logger && require('fwsp-logger').initHydraExpress(
  hydraExpress, config.hydra.serviceName, config.logger
);
return hydraExpress.init(config.getObject(), version, () => {
  const express = hydraExpress.getExpress();
  let logRequests = config.environment === 'development' && config.logger.logRequests;
  logger && logRequests && hydraExpress.getExpressApp().use(logger.middleware);
  hydraExpress.registerRoutes({
    '/v1/service': require('./routes/service-v1-routes')
  });
})

with corresponding entry in config.json:

"logger": {
  "name": "optional - will default to service name",
  "logPath": "optional - will default to service/servicename.log",
  "toConsole": false, // don't log to console
  "noFile": true, // don't log to disk
  "logRequests": true, // log all requests in development env
  "redact": ["password"], // fields to redact when logging req.body
  "elasticsearch": {
    "host": "localhost",
    "port": 9200
  }
},

General usage:

const Logger = require('fwsp-logger').Logger,
      logger = new Logger(
        { name: 'myApp' },
        { host: 'your.elasticsearch.host.com', port: 9200 }
    );
const appLogger = logger.getLogger();
appLogger.error('An error happened');
appLogger.info('Something else happened');

Testing

To make sure logs are getting shipped to Elasticsearch, you can spin up docker containers with ES and Kibana using the docker-compose.yml file in this repository.

You will need docker and docker-compose installed, then in this project folder, launch docker-compose up.

License

Licensed under MIT.

Keywords

FAQs

Package last updated on 02 Dec 2016

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