Comparing version 0.1.0-beta-7 to 0.1.0-beta-8
@@ -30,2 +30,3 @@ "use strict"; | ||
config: Type.OBJECT, | ||
length: Type.NUMBER, | ||
hooks: Type.ARRAY | ||
@@ -36,4 +37,4 @@ }, | ||
var file; | ||
this.stream = null; | ||
this.server = null; | ||
this.length = 0; | ||
this.stream = this.server = null; | ||
this.hooks = []; | ||
@@ -45,2 +46,3 @@ this.config = core.extend({ | ||
console: false, | ||
readLength: 20000, | ||
port: 9001, | ||
@@ -55,8 +57,36 @@ file: "server.log", | ||
if (this.config.publish) { | ||
this.server = http.createServer(); | ||
this.server.on('request', function (request, response) { | ||
var read = fs.readFileSync(file); | ||
response.writeHead(200, {'Content-type': 'text/plain', 'Content-Length': read.length}); | ||
response.end(read); | ||
}); | ||
var len = this.length, | ||
start = len - this.config.readLength, | ||
blen = 0, | ||
buffer, | ||
blenMessage; | ||
if (start < 0) { | ||
start = 0; | ||
blen = 1000; | ||
} else { | ||
blen = len - start; | ||
} | ||
blenMessage = 'LAST '+ blen + ' BYTES:\n\n'; | ||
buffer = new Buffer(blen + blenMessage.length, 'utf8'); | ||
fs.open(file, 'r', 755, function(status, fd) { | ||
fs.read(fd, buffer, 0, blen, start, function(err) { | ||
if (err) { | ||
var errorMessage = 'Error reading logger buffer'; | ||
response.writeHead(200, {'Content-type': 'text/plain', 'Content-Length': errorMessage.length}); | ||
response.end(errorMessage); | ||
} else { | ||
response.writeHead(200, {'Content-type': 'text/plain', 'Content-Length': buffer.length}); | ||
response.write(blenMessage); | ||
response.end(buffer); | ||
} | ||
}); | ||
}); | ||
}.bind(this)); | ||
this.server.listen(this.config.port); | ||
@@ -146,2 +176,3 @@ this.print('Publishing log write stream on port: ' + this.config.port); | ||
try { | ||
this.length += logs.length; | ||
this.stream.write(logs); | ||
@@ -148,0 +179,0 @@ } catch (e) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Powerful lightweight mvc framework for nodejs", | ||
"version": "0.1.0-beta-7", | ||
"version": "0.1.0-beta-8", | ||
"dependencies" : { | ||
@@ -8,0 +8,0 @@ "mongoose": "3.8.x", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105012
3322