Comparing version 0.0.2 to 0.0.3
@@ -10,2 +10,3 @@ if (console._LOG_BUFFER) return; | ||
process.on('exit', flush); | ||
// export the flush and patch functions | ||
@@ -31,3 +32,3 @@ module.exports = patch; | ||
*/ | ||
function patch(limit) { | ||
function patch(limit, pre) { | ||
limit = limit || 8192; // 8kb | ||
@@ -40,2 +41,4 @@ | ||
var s = util.format.apply(this, arguments); | ||
if (typeof pre === 'string') s = pre + s; | ||
else if (typeof pre === 'function') s = pre() + s; | ||
@@ -42,0 +45,0 @@ // calculate the new length |
{ | ||
"name": "log-buffer", | ||
"description": "Buffer calls to console.log, console.warn, etc. for high performance logging", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "Dave Eddy <dave@daveeddy.com> (http://www.daveeddy.com)", | ||
@@ -6,0 +6,0 @@ "contributors": [], |
@@ -42,2 +42,16 @@ log-buffer | ||
You can specify a function or string to prefix all log statements | ||
```js | ||
require('log-buffer')(4096, 'MyLog: '); | ||
``` | ||
All log statements will be prepended `MyLog: ` when flushed. | ||
``` js | ||
require('log-buffer')(4096, function() { return new Date().toISOString() + ': '; }); | ||
``` | ||
All log statements will be prepended by `2013-04-27T04:37:24.703Z: ` for example | ||
This module also exposes the `flush` function used to flush all buffers, so | ||
@@ -44,0 +58,0 @@ if you would like you can manually invoke a flush. |
7774
9
83
182