Permalink
Browse files

Improve Logging (sadly breaks it)

  • Loading branch information...
1 parent 7d095ff commit 8e917f07394ba2c1529afd0d1b3c886856cee0ef root committed Apr 9, 2012
Showing with 17 additions and 5 deletions.
  1. +11 −4 app.js
  2. +4 −0 logger.js
  3. +2 −1 package.json
View
@@ -1,6 +1,13 @@
/**
* Module dependencies.
*/
+require("./logger").init();
+var logger = require('./logger').logger;
+logger.use(require('devnull/transports/stream'), {
+ stream: require('fs').createWriteStream('loggers.log')
+});
+
+logger.log("test");
var express = require('express')
, routes = require('./routes')
@@ -22,7 +29,6 @@ app.configure(function(){
var startTime = new Date();
var old = 0;
console.log("Starting upload");
- console.log(new Date().getTime());
//We can't use progressbars because there are two files at the same time.
form.on('progress', function(received, expected) {
//console.log(this.requestHeader);
@@ -32,9 +38,10 @@ app.configure(function(){
});
form.on('end', function() {
var timeTaken = (new Date().getTime() - startTime.getTime()) / 1000;
-console.log((req.headers['content-length']/1024)/timeTaken + " kb/s")
-console.log(timeTaken);
-
+ var kbs = ((req.headers['content-length']/1024)/timeTaken);
+ console.log(timeTaken + " - " + kbs + "kb/s");
+ console.log(req);
+// logger.log((req.headers['content-length']/1024) + " - "+ timeTaken + " (" + kbs + "kb/s)");
});
form.parse(req);
}
View
@@ -0,0 +1,4 @@
+exports.init = function() {
+ var Logger = require('devnull');
+ exports.logger = new Logger({ base: true });
+};
View
@@ -11,5 +11,6 @@
, "ejs": ">= 0.0.1"
, "formidable": ">= 0.0.1"
, "progress-bar": ">= 0.0.1"
+ , "devnull": ">= 0.0.1"
}
-}
+}

0 comments on commit 8e917f0

Please sign in to comment.