Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ability to process log before outputting

  • Loading branch information...
commit 1d642dd2ae6ccdd7d0e783c3d758711f934cf3d4 1 parent 8dfbee0
@bobrik authored
View
13 README.md
@@ -17,6 +17,7 @@ Everybody loves screenshots!
* Link activation in logs - just click on it to open.
* Whole system and current log activity state indication.
* Support for plain text, html and color ansi (yep, like in your terminal) logs.
+* Custom filters for log lines before outputting. Colorize if you want to.
* Open-source. Can you imagine that?
## Demo
@@ -57,6 +58,18 @@ PuperGrep needs to know what to monitor. Simple server to make you understand wh
// or has ANSI escape sequences
// manager.setLogType("my_cool_log", "ansi");
+ // if you want to colorize your log before outputting as html:
+ // manager.getLogReader("my_cool_log", function(error, reader) {
+ // if (error) {
+ // console.log(error);
+ // return;
+ // }
+ //
+ // reader.setProcessor(function(line, callback) {
+ // callback(undefined, "<span style="color: red;>" + line + "</span>");
+ // });
+ // });
+
puper.listen(8080, "127.0.0.1");
});
})();
View
24 lib/LogReader.js
@@ -23,6 +23,14 @@
return this.buffer;
};
+ LogReader.prototype.process = function(line, callback) {
+ callback(undefined, line);
+ };
+
+ LogReader.prototype.setProcessor = function(processor) {
+ this.process = processor;
+ };
+
LogReader.prototype.attach = function() {
if (this.attached) {
return;
@@ -35,12 +43,18 @@
self.tail.stdout.on("data", function(data) {
data.toString().split("\n").forEach(function(line) {
if (line.length != 0) {
- self.buffer.push(line);
- while (self.buffer.length > self.length) {
- self.buffer.shift();
- }
+ self.process(line, function(error, line) {
+ if (error) {
+ return;
+ }
+
+ self.buffer.push(line);
+ while (self.buffer.length > self.length) {
+ self.buffer.shift();
+ }
- self.emit("line", line);
+ self.emit("line", line);
+ });
}
});
});
View
2  lib/LogReaderManager.js
@@ -22,7 +22,7 @@
if (this.logs[name]) {
this.logs[name].type = type;
}
- }
+ };
LogReaderManager.prototype.getLogReader = function(name, callback) {
if (!this.readers[name]) {
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "pupergrep",
- "version": "0.6.2",
+ "version": "0.6.3",
"description": "Real-time grep for your logs right in your favorite modern browser made with Twitter Bootstrap.",
"main": "index.js",
"dependencies": {
Please sign in to comment.
Something went wrong with that request. Please try again.