Skip to content

yannickcr/node-chromelogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node Chrome Logger

Maintenance Status NPM version Build Status Dependency Status Coverage Status Code Climate

Chrome Logger is a Google Chrome extension for debugging server side applications in the Chrome console. This module is an implementation of the Chrome Logger protocol for Node.js, it allows you to log and inspect your server-side code directly in the Chrome console.

Installation

$ npm install chromelogger

and install the Chrome Logger extension in your Chrome browser.

Usage

var chromelogger = require('chromelogger');
var http = require('http');

var server = http.createServer();

server.on('request', chromelogger.middleware);

server.on('request', function(req, res) {
  res.chrome.log('Hello from Node.js %s', process.version);
  res.end('Hello World');
});

server.listen(7357);

Node Chrome Logger provide several logging methods on the ServerResponse (res) object:

  • res.chrome.log
  • res.chrome.warn
  • res.chrome.error
  • res.chrome.info
  • res.chrome.table
  • res.chrome.assert
  • res.chrome.count
  • res.chrome.time
  • res.chrome.timeEnd
  • res.chrome.group
  • res.chrome.groupEnd
  • res.chrome.groupCollapse

These methods matches the Console API of the Chrome Developer Tools.

Usage as an Express middleware

var chromelogger = require('chromelogger');
var express = require('express');

var app = express();

app.use(chromelogger.middleware);

app.get('/', function(req, res) {
  res.chrome.log('Hello from Express.js %s', express.version);
  res.end('Hello World');
});

app.listen(7357);

Events

error: if an error occur (headers too large, logging after the headers were already sent)

chromelogger.on('error', function(message) {
  console.log(message);
});

License

Node Chrome Logger is licensed under the MIT License.

About

Implementation of the Chrome Logger protocol for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published