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

logware

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logware

Easy, flexible and clear Express middleware logging

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
1
Weekly downloads
 
Created
Source

logware

Simple, flexible and unobtrusive console-logging middleware for Express. Will look great in your devDependencies.

Why?

Because you want to see the journey your req and res objects are taking once your route is hit, or you just want to log something to prove things are going where you expect.

Why... this?

Because you want your logging to be

  • colourful
  • clearly demarcated and easy to read
  • numbered, so you can easily tell which is which
  • easy to add, with no need to type something hideous and then find the app has crashed because of a missing bracket or comma
  • ERROR FREE. This library is unlikely ever to throw an error. Nobody wants that from console logging.

It's also free from dependencies.

How?

import lw from 'logware';

app.post('/route',
  middleware1,
  lw({ req: 'body.data.thing' }), // tell logware what to log
  middleware2,
  lw({ req: 'user', res: ['app.data', 'locals.thing']}), // you can use an array to log multiple things
  middleware3,
  lw('Hello!!!'), // or just pass a message
  middleware4,
  lw({ message: 'Hello', req: 'body', res: ['app.data', 'locals.thing']}), // or do it all!
  middleware5
);

Logs look like this

╔══
║ 1. hello



  req.prop
  ───────
  'foo bar'



  res.locals.data.thing
  ──────────────────
  'bar foo'

// some log from your real middleware

╔══
║ 2. another log



  req.number
  ─────────
  8.988784079044443

Also

You can tell logware to log a certain message or certain properties every time using the options object, which works exactly the same way as the object you would pass to lw():

lw.options = {
  message: 'This will be logged every time',
  req: 'params.thingToLogEveryTime',
  res: 'headersSent'
};

// these things will be logged each time lw() is used, along with anything passed in

Yes...

This middleware does add a tiny _logwareCounter property to the response's locals object. It's hard to see how this could affect your app at all though (especially as you shouldn't be using this library anywhere but locally) unless you really want it to, in which case more power to you.

FAQs

Package last updated on 03 Oct 2017

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