@wittcode/console-log-middleware
v0.1.3
Published
Express middleware that modifies console methods to send logs to the ConsoleLog chrome extension.
Downloads
44
Readme
ConsoleLog
- Install the chrome extension ConsoleLog at the URL: ConsoleLog.
- Download this npm package.
- Create an express application and add the middleware (see code below).
- Now any console.log, console.error, etc. message will be displayed as an alert in the browser.
Example usage:
import express from 'express';
import consoleLogMiddleware from '@wittcode/console-log-middleware';
const app = express();
const PORT = 3000;
// Enable the middleware
app.use(
consoleLogMiddleware({
enabled: true, // Turns on the middleware
logToConsole: true, // Keeps logs showing in your terminal as well
})
);
app.get('/', (req, res) => {
console.warn('This will be sent to the browser via headers.', {user: 'WittCode', options: {a: 1, b: 2}});
res.send('<h1>Hello World</h1>');
});
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});