npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@exzeo/winston-logsene

v1.2.1

Published

Winston transport layer for Logsene

Downloads

28

Readme

This is a transport module for the winston logger winstonjs/winston for logging with Logsene by Sematext.

Winston-Logsene combines the flexibility of using the Winston logging framework with Logsene (think Hosted Elasticsearch + Kibana). Create your free account and access token here.

Usage


var winston = require('winston')
var logsene = require('winston-logsene') 
var logger = new winston.Logger()
logger.add (logsene, {
  token: process.env.LOGSENE_TOKEN, 
  type: 'test_logs', 
  url: 'https://logsene-receiver.sematext.com/_bulk'
})

Options

  • token - Create your free account and access token here.
  • type - Type of your logs - please note you can define Elasticsearch mapping templates in Logsene
  • url - Logsene receiver URL (e.g. for Logsene On Premises), defaults to Sematext Cloud (US) receiver https://logsene-receiver.sematext.com/_bulk. To ship logs to Sematext Cloud (EU) in Europe use https://logsene-receiver.eu.sematext.com/_bulk
  • handleExceptions - boolean 'true' logs 'uncaught exceptions'
  • exitOnError - if set to 'false' process will not exit after logging the 'uncaught exceptions'
  • source - name of the logging source, by default name of the main node.js module
  • setSource - "true" adds "source" to the log event (modifies the object!), default false
  • rewriter - similar to rewriters in winston, rewriter allows modifying of log meta but only for the logsene transport. This is a simple function which takes level, msg, meta as parameter and returns the new meta array
  • flushOnExit - Handling SIGTERM, SIGQUIT, SIGINT and 'beforeExit' to flush logs and terminate. Default value: true.

Examples

// use dynamic list of placeholders and parameters and any Object as Metadata
// message placeholders work the same way as in util.format()
logger.info ('Info Message')
// utilize tags (in the metadata object) as filter to be used in Logsene UI
logger.info ('Info Message', {tags: ['info', 'test']})
logger.info ("Info message no. %d logged to %s",1,'Logsene', {metadata: "test-log", count:1 , tags: ['test', 'info', 'winston']})
logger.error ("Error message no. %d logged to %s",1,'Logsene', {metadata: "test-error", count:1, tags: ['test', 'error', 'winston']})
logger.warn ("Warning message no. %d logged to %s",1,'Logsene', {metadata: "test-warning", count:1, tags: ['test', 'warning', 'winston']})
logger.debug ("Debug message no. %d logged to %s",1,'Logsene', {metadata: "test-debug", count:1})

// use custom rewriter
var serverIp = "10.0.0.12";
logger.add (logsene, {
    token: process.env.LOGSENE_TOKEN,
    rewriter: function (level, msg, meta) {
      meta.ip = serverIp;
      return meta;
    }
})

Schema / Mapping definition for Meta-Data

It is possible to log any JSON Object as meta data, but please note Logsene stores data in Elasticsearch and therefore you should define an index template, matching your data structure. More about Elasticsearch mapping and templates for Logsene: http://blog.sematext.com/2015/01/20/custom-elasticsearch-index-templates-in-logsene/

In addition you should use different types for different meta data structures to avoid type conflicts in Elasticsearch. Include a type name in the meta-data like {type: 'logType1', ...} - this overwrites the "type" property, specified in the contstructor.

logger.add (logsene, {token: process.env.LOGSENE_TOKEN, type: 'my_logs'})
// numeric id, log type from constructor
logger.info('hello', {id: 1})
// The next line will cause a type conflict in Elasticsearch/Logsene, because id was a number before
logger.info('hello', {id: 'ID-1'}) 
// using a different type, OK no type conflict for the field 'id' in Elasticsearch/Logsene
// because we use a different type in the Elasticsearch/Logsene index 
logger.info('hello', {type: 'my_type_with_string_ids',{id: 'ID-1'})

Security

  • HTTPS is enabled by default
  • Environment variables for Proxy servers:
    • For HTTPS endpoints (default): HTTPS_PROXY / https_proxy
        export HTTPS_PROXY=https://my-ssl-proxy.example
        export HTTPS_PROXY=http://my-proxy.example
  • For HTTP endpoints (e.g. On-Premises): HTTP_PROXY / http_proxy
        export HTTP_PROXY=http://my-proxy.example
        export HTTP_PROXY=https://my-ssl-proxy.example

License

Apache 2, see LICENSE file