more winston, issue #62

This commit is contained in:
Baris Usakli
2013-08-13 16:00:24 -04:00
parent 1856e394f3
commit dceec0ce46
13 changed files with 43 additions and 51 deletions

View File

@@ -4,7 +4,8 @@ var user = require('./../user.js'),
fs = require('fs'),
utils = require('./../../public/src/utils.js'),
path = require('path'),
marked = require('marked');
marked = require('marked'),
winston = require('winston');
(function(User) {
User.create_routes = function(app) {
@@ -136,7 +137,7 @@ var user = require('./../user.js'),
fs.unlink(absolutePath, function(err) {
if(err) {
console.error('[%d] %s', Date.now(), + err);
winston.error('[%d] %s', Date.now(), + err);
}
uploadUserPicture(req.user.uid, path.extname(req.files.userPhoto.name), req.files.userPhoto.path, res);
@@ -155,8 +156,7 @@ var user = require('./../user.js'),
var filename = uid + '-profileimg' + extension;
var uploadPath = path.join(global.configuration['ROOT_DIRECTORY'], global.nconf.get('upload_path'), filename);
// @todo move to proper logging code - this should only be temporary
console.log('Info: Attempting upload to: '+ uploadPath);
winston.info('Attempting upload to: '+ uploadPath);
var is = fs.createReadStream(tempPath);
var os = fs.createWriteStream(uploadPath);
@@ -176,11 +176,7 @@ var user = require('./../user.js'),
height: 128
}, function(err, stdout, stderr){
if (err) {
// @todo: better logging method; for now, send to stderr.
// ideally, this should be happening in another process
// to avoid poisoning the main process on error or allowing a significant problem
// to crash the main process
console.error('[%d] %s', Date.now(), + err);
winston.err(err.message, err.stack);
}
res.json({ path: imageUrl });
@@ -189,7 +185,7 @@ var user = require('./../user.js'),
});
os.on('error', function(err) {
console.error('[%d] %s', Date.now(), + err);
winston.error('[%d] %s', Date.now(), + err);
});
is.pipe(os);