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

simple-express-json-logger

v1.1.3

Published

A simple middleware for express that logs in a json format.

Downloads

24

Readme

simple-express-json-logger

simple-express-json-logger is a simple express middleware that will output a very simple log in JSON format.

requestTimeLength is in milliseconds.

Usage

var express = require('express');
var simpleJsonLogger = require('simple-express-json-logger');
// Setup your express app
var app = express();
app.use(simpleJsonLogger.logger);

Now on every request, you'll get something similar to this:

{"path":"/","method":"GET","requestTimeLength":"6.55","ua":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36","ip":"::1","time":"2015-10-21 13:35:37"}

Logstash UDP support

If you supply a host and a port when you initiate simple-express-json-logger, you'll get log entries to your UDP server.

var express = require('express');
var simpleJsonLogger = require('simple-express-json-logger');
// Setup your express app
var app = express();
// Send message via udp to logstash.server.com:12345
app.use(simpleJsonLogger.logger('logstash.server.com', 12345));

Setup your logstash server like so:

input {
  udp {
    port => 12345
    type => 'node-logs' // Or whatever you want the logs to show up as
    codec => 'json'
  }
  output {
    // Whatever you want
  }
}

You can also use the optional flag to turn off the console.log message so you can get only the UDP message sent.

app.use(simpleJsonLogger.logger('logstash.server.com', 12345, { disableConsole: true }));

You can log environmental variables as well, like by adding them to the array in your options:

app.use(simpleJsonLogger('logstash.server.com', 12345, {
  loggedFromEnv: ['envVar1', 'envVar2']
));

You can also add arbitrary tags that will get forwarded to your logs.

app.use(simpleJsonLogger.logger('logstash.server.com', 12345, {
  tags: ['web server 1', 'staging environment']
));

License

simple-express-json-logger is licensed under ISC.

About

simple-express-json-logger was developed by the team at Wedgies.

Wedgies is a digital survey platform that gives media, journalists and brands in-line survey capabilities inside social media, their website, and their apps — where they can collect millions of opinions from their readers and users. Wedgies is the leading social survey platform that enables publishers to collect survey respondents directly within social media streams.

Wedgies, a darling of Tony Hsieh’s Las Vegas’ Vegas Tech Fund, is backed by an all-star list of investors including Greycroft, Advancit Capital, MESA Ventures, Knight Foundation, kbs+ Ventures, Battle Born Ventures, Twilio, 500 Startups and SV Angel.

Wedgies founding team consists of top talent in developer tools and community management with experience that includes Zappos.com, Overstock.com, and Backcountry.com.

Built with Wedgies