stream-log-stats
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -10,4 +10,2 @@ | ||
var throttledRender = f.throttle(view.render, { restPeriod: 500 }); | ||
module.exports = function(options){ | ||
@@ -22,4 +20,6 @@ var clf = new Clf(options); | ||
if (!(this instanceof StatsView)) return new StatsView(options); | ||
options = options || {}; | ||
Transform.call(this, options); | ||
this._buffer = ""; | ||
this.throttledRender = f.throttle(view.render, { restPeriod: options.refreshRate || 500 }); | ||
} | ||
@@ -41,3 +41,3 @@ util.inherits(StatsView, Transform); | ||
this._buffer = input.replace(matches.join(""), ""); | ||
throttledRender(stats); | ||
this.throttledRender(stats); | ||
} else { | ||
@@ -44,0 +44,0 @@ this._buffer = input; |
@@ -6,3 +6,4 @@ "use strict"; | ||
fs = require("fs"), | ||
path = require("path"); | ||
path = require("path"), | ||
ansi = require("ansi-escape-sequences"); | ||
@@ -17,2 +18,3 @@ exports.render = render; | ||
function render(stats){ | ||
stats = addLayoutData(stats); | ||
var rendered = compiled(stats); | ||
@@ -34,1 +36,20 @@ | ||
} | ||
function addLayoutData(stats){ | ||
var cols = process.stdout.columns; | ||
stats.table3 = { col1: {}, col2: {}, col3: {} }; | ||
stats.table3.col2.header = ansi.format("Requests", "underline"); | ||
stats.table3.col2.headerWidth = stats.table3.col2.header.length + 1; | ||
stats.table3.col2.width = "Requests".length + 1; | ||
stats.table3.col3.header = ansi.format("Transferred", "underline"); | ||
stats.table3.col3.headerWidth = stats.table3.col3.header.length + 1; | ||
stats.table3.col3.width = "Transferred".length + 1; | ||
stats.table3.col1.header = ansi.format("Resource", "underline"); | ||
stats.table3.col1.width = cols - stats.table3.col2.width - stats.table3.col3.width; | ||
stats.table3.col1.headerWidth = stats.table3.col1.width + ansi.format("", "underline").length; | ||
stats.table3.col1.clipLeft = stats.table3.col1.width - 2; | ||
return stats; | ||
} |
{ | ||
"name": "stream-log-stats", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Prints statistics from the incoming web log stream to the console", | ||
@@ -23,2 +23,3 @@ "repository": "https://github.com/75lb/stream-log-stats.git", | ||
"dependencies": { | ||
"ansi-escape-sequences": "^0.1.0", | ||
"boil-js": "^0.1.4", | ||
@@ -25,0 +26,0 @@ "byte-size": "^0.1.0", |
@@ -21,2 +21,3 @@ [![view on npm](http://img.shields.io/npm/v/stream-log-stats.svg)](https://www.npmjs.org/package/stream-log-stats) | ||
var connect = require("connect"), | ||
morgan = require("morgan"), // logging middleware | ||
http = require("http"), | ||
@@ -41,3 +42,3 @@ logStats = require("stream-log-stats"); | ||
This example pipes the output from [local-web-server](https://www.npmjs.org/package/local-web-server) into `log-stats`. | ||
```sh | ||
``` | ||
$ ws -f default | log-stats | ||
@@ -44,0 +45,0 @@ serving at http://localhost:8000 |
Sorry, the diff of this file is not supported yet
10382
156
71
7
+ Addedansi-escape-sequences@^0.1.0
+ Addedansi-escape-sequences@0.1.1(transitive)