Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Simple, flexible and unobtrusive console-logging middleware for Express. Will look great in your devDependencies
.
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.
Because you want your logging to be
It's also free from dependencies.
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
);
╔══
║ 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
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
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
Easy, flexible and clear Express middleware logging
The npm package logware receives a total of 3 weekly downloads. As such, logware popularity was classified as not popular.
We found that logware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.