mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
more winston, issue #62
This commit is contained in:
@@ -30,10 +30,6 @@ var socket,
|
||||
app.alert(data);
|
||||
});
|
||||
|
||||
socket.on('event:consolelog', function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
socket.on('connect', function(data){
|
||||
if(reconnecting) {
|
||||
setTimeout(function(){
|
||||
|
||||
@@ -110,7 +110,6 @@
|
||||
contentEl.addEventListener('click', function(e) {
|
||||
if (e.target.hasAttribute('data-path')) {
|
||||
var href = 'install/' + e.target.getAttribute('data-path');
|
||||
console.log(href);
|
||||
if (!e.target.disabled) ajaxify.go(href);
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -9,7 +9,8 @@ var RDB = require('./redis.js'),
|
||||
plugins = require('./plugins'),
|
||||
reds = require('reds'),
|
||||
postSearch = reds.createSearch('nodebbpostsearch'),
|
||||
topicSearch = reds.createSearch('nodebbtopicsearch');
|
||||
topicSearch = reds.createSearch('nodebbtopicsearch'),
|
||||
winston = require('winston');
|
||||
|
||||
(function(PostTools) {
|
||||
PostTools.isMain = function(pid, tid, callback) {
|
||||
@@ -111,7 +112,7 @@ var RDB = require('./redis.js'),
|
||||
threadTools.get_latest_undeleted_pid(postData.tid, function(err, pid) {
|
||||
if (err && err.message === 'no-undeleted-pids-found') {
|
||||
threadTools.delete(postData.tid, -1, function(err) {
|
||||
if (err) console.log('Error: Could not delete topic (tid: ' + postData.tid + ')');
|
||||
if (err) winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack);
|
||||
});
|
||||
} else {
|
||||
posts.getPostField(pid, 'timestamp', function(timestamp) {
|
||||
|
||||
@@ -11,7 +11,8 @@ var RDB = require('./redis.js'),
|
||||
plugins = require('./plugins'),
|
||||
reds = require('reds'),
|
||||
nconf = require('nconf'),
|
||||
postSearch = reds.createSearch('nodebbpostsearch');
|
||||
postSearch = reds.createSearch('nodebbpostsearch'),
|
||||
winston = require('winston');
|
||||
|
||||
(function(Posts) {
|
||||
|
||||
@@ -298,7 +299,7 @@ var RDB = require('./redis.js'),
|
||||
|
||||
uploadPostImages(postData, images, function(err, uploadedImages) {
|
||||
if(err) {
|
||||
console.log('Uploading images failed!');
|
||||
winston.error('Uploading images failed!', err.stack);
|
||||
} else {
|
||||
postData.uploadedImages = JSON.stringify(uploadedImages);
|
||||
Posts.setPostField(pid, 'uploadedImages', postData.uploadedImages);
|
||||
|
||||
10
src/redis.js
10
src/redis.js
@@ -1,7 +1,8 @@
|
||||
(function(RedisDB) {
|
||||
var redis = require('redis'),
|
||||
nconf = require('nconf'),
|
||||
utils = require('./../public/src/utils.js');
|
||||
utils = require('./../public/src/utils.js'),
|
||||
winston = require('winston');
|
||||
|
||||
RedisDB.exports = redis.createClient(nconf.get('redis:port'), nconf.get('redis:host'));
|
||||
|
||||
@@ -11,14 +12,9 @@
|
||||
|
||||
RedisDB.exports.handle = function(error) {
|
||||
if (error !== null) {
|
||||
winston.err(error);
|
||||
if (global.env !== 'production') {
|
||||
console.log("################# ERROR LOG ####################");
|
||||
console.log(error);
|
||||
console.log(arguments.callee.name);
|
||||
console.log("################# ERROR LOG ####################");
|
||||
throw new Error(error);
|
||||
} else {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ var user = require('./../user.js'),
|
||||
finalData[key] = jsonObject[key];
|
||||
}
|
||||
} catch(err){
|
||||
console.log('invalid redis status', i, data[i], err);
|
||||
winston.warn('can\'t parse redis status variable, ignoring', i, data[i], err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ var user = require('./../user.js'),
|
||||
search(topicSearch, function(err, tids) {
|
||||
if(err)
|
||||
return callback(err, null);
|
||||
console.log(tids);
|
||||
|
||||
topics.getTopicsByTids(tids, 0, function(topics) {
|
||||
callback(null, topics);
|
||||
}, 0);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
login_strategies = [],
|
||||
nconf = require('nconf'),
|
||||
users = require('../user'),
|
||||
winston = require('winston'),
|
||||
login_module = require('./../login.js');
|
||||
|
||||
passport.use(new passportLocal(function(user, password, next) {
|
||||
@@ -85,7 +86,7 @@
|
||||
|
||||
app.get('/logout', function(req, res) {
|
||||
if (req.user && req.user.uid > 0) {
|
||||
console.log('info: [Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
||||
winston.info('[Auth] Session ' + req.sessionID + ' logout (uid: ' + req.user.uid + ')');
|
||||
login_module.logout(req.sessionID, function(logout) {
|
||||
req.logout();
|
||||
app.build_header({ req: req, res: res }, function(err, header) {
|
||||
@@ -132,7 +133,6 @@
|
||||
|
||||
app.get('/reset', function(req, res) {
|
||||
app.build_header({ req: req, res: res }, function(err, header) {
|
||||
console.log(header);
|
||||
res.send(header + templates['reset'] + templates['footer']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -6,7 +6,8 @@ var RDB = require('./redis.js'),
|
||||
notifications = require('./notifications.js'),
|
||||
posts = require('./posts'),
|
||||
reds = require('reds'),
|
||||
topicSearch = reds.createSearch('nodebbtopicsearch');
|
||||
topicSearch = reds.createSearch('nodebbtopicsearch'),
|
||||
winston = require('winston');
|
||||
|
||||
(function(ThreadTools) {
|
||||
|
||||
@@ -192,7 +193,7 @@ var RDB = require('./redis.js'),
|
||||
|
||||
categories.moveRecentReplies(tid, oldCid, cid, function(err, data) {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
winston.err(err);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var RDB = require('./redis.js'),
|
||||
async = require('async');
|
||||
|
||||
async = require('async'),
|
||||
winston = require('winston');
|
||||
|
||||
|
||||
function upgradeCategory(cid, callback) {
|
||||
@@ -20,7 +20,6 @@ function upgradeCategory(cid, callback) {
|
||||
|
||||
async.each(tids, moveTopic, function(err) {
|
||||
if(!err) {
|
||||
console.log('renaming ' + cid);
|
||||
RDB.rename('temp_categories:' + cid + ':tid', 'categories:' + cid + ':tid');
|
||||
callback(null);
|
||||
}
|
||||
@@ -30,7 +29,7 @@ function upgradeCategory(cid, callback) {
|
||||
|
||||
});
|
||||
} else {
|
||||
console.log('category already upgraded '+ cid);
|
||||
winston.info('category already upgraded '+ cid);
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
@@ -52,33 +51,37 @@ function upgradeUser(uid, callback) {
|
||||
|
||||
exports.upgrade = function() {
|
||||
|
||||
console.log('upgrading nodebb now');
|
||||
winston.info('upgrading nodebb now');
|
||||
|
||||
var schema = [
|
||||
function upgradeCategories(next) {
|
||||
console.log('upgrading categories');
|
||||
winston.info('upgrading categories');
|
||||
|
||||
RDB.lrange('categories:cid', 0, -1, function(err, cids) {
|
||||
|
||||
async.each(cids, upgradeCategory, function(err) {
|
||||
if(!err)
|
||||
next(null, 'upgraded categories');
|
||||
else
|
||||
if(!err) {
|
||||
winston.info('upgraded categories');
|
||||
next(null, null);
|
||||
} else {
|
||||
next(err, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
function upgradeUsers(next) {
|
||||
console.log('upgrading users');
|
||||
winston.info('upgrading users');
|
||||
|
||||
RDB.lrange('userlist', 0, -1, function(err, uids) {
|
||||
|
||||
async.each(uids, upgradeUser, function(err) {
|
||||
if(!err)
|
||||
next(null, 'upgraded users');
|
||||
else
|
||||
if(!err) {
|
||||
winston.info('upgraded users')
|
||||
next(null, null);
|
||||
} else {
|
||||
next(err, null);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -87,9 +90,9 @@ exports.upgrade = function() {
|
||||
|
||||
async.series(schema, function(err, results) {
|
||||
if(!err)
|
||||
console.log('upgrade complete');
|
||||
winston.info('upgrade complete');
|
||||
else
|
||||
console.log(err);
|
||||
winston.err(err);
|
||||
|
||||
process.exit();
|
||||
|
||||
|
||||
@@ -108,7 +108,6 @@ var express = require('express'),
|
||||
|
||||
// respond with html page
|
||||
if (req.accepts('html')) {
|
||||
|
||||
//res.json('404', { url: req.url });
|
||||
res.redirect(global.nconf.get('relative_path') + '/404');
|
||||
return;
|
||||
@@ -116,7 +115,6 @@ var express = require('express'),
|
||||
|
||||
// respond with json
|
||||
if (req.accepts('json')) {
|
||||
console.log('sending 404 json');
|
||||
res.send({ error: 'Not found' });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
'categories': require('./admin/categories.js'),
|
||||
'user': require('./admin/user.js')
|
||||
},
|
||||
plugins = require('./plugins');
|
||||
plugins = require('./plugins'),
|
||||
winston = require('winston');
|
||||
|
||||
(function(io) {
|
||||
var users = {},
|
||||
@@ -668,7 +669,7 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
|
||||
user.getUsers(data.set, start, end, function(err, data) {
|
||||
if(err) {
|
||||
console.log(err);
|
||||
winston.err(err);
|
||||
} else {
|
||||
callback({users:data});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user