mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
more winston, issue #62
This commit is contained in:
@@ -30,10 +30,6 @@ var socket,
|
|||||||
app.alert(data);
|
app.alert(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('event:consolelog', function(data) {
|
|
||||||
console.log(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('connect', function(data){
|
socket.on('connect', function(data){
|
||||||
if(reconnecting) {
|
if(reconnecting) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
|
|||||||
@@ -110,7 +110,6 @@
|
|||||||
contentEl.addEventListener('click', function(e) {
|
contentEl.addEventListener('click', function(e) {
|
||||||
if (e.target.hasAttribute('data-path')) {
|
if (e.target.hasAttribute('data-path')) {
|
||||||
var href = 'install/' + e.target.getAttribute('data-path');
|
var href = 'install/' + e.target.getAttribute('data-path');
|
||||||
console.log(href);
|
|
||||||
if (!e.target.disabled) ajaxify.go(href);
|
if (!e.target.disabled) ajaxify.go(href);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ var RDB = require('./redis.js'),
|
|||||||
plugins = require('./plugins'),
|
plugins = require('./plugins'),
|
||||||
reds = require('reds'),
|
reds = require('reds'),
|
||||||
postSearch = reds.createSearch('nodebbpostsearch'),
|
postSearch = reds.createSearch('nodebbpostsearch'),
|
||||||
topicSearch = reds.createSearch('nodebbtopicsearch');
|
topicSearch = reds.createSearch('nodebbtopicsearch'),
|
||||||
|
winston = require('winston');
|
||||||
|
|
||||||
(function(PostTools) {
|
(function(PostTools) {
|
||||||
PostTools.isMain = function(pid, tid, callback) {
|
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) {
|
threadTools.get_latest_undeleted_pid(postData.tid, function(err, pid) {
|
||||||
if (err && err.message === 'no-undeleted-pids-found') {
|
if (err && err.message === 'no-undeleted-pids-found') {
|
||||||
threadTools.delete(postData.tid, -1, function(err) {
|
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 {
|
} else {
|
||||||
posts.getPostField(pid, 'timestamp', function(timestamp) {
|
posts.getPostField(pid, 'timestamp', function(timestamp) {
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ var RDB = require('./redis.js'),
|
|||||||
plugins = require('./plugins'),
|
plugins = require('./plugins'),
|
||||||
reds = require('reds'),
|
reds = require('reds'),
|
||||||
nconf = require('nconf'),
|
nconf = require('nconf'),
|
||||||
postSearch = reds.createSearch('nodebbpostsearch');
|
postSearch = reds.createSearch('nodebbpostsearch'),
|
||||||
|
winston = require('winston');
|
||||||
|
|
||||||
(function(Posts) {
|
(function(Posts) {
|
||||||
|
|
||||||
@@ -298,7 +299,7 @@ var RDB = require('./redis.js'),
|
|||||||
|
|
||||||
uploadPostImages(postData, images, function(err, uploadedImages) {
|
uploadPostImages(postData, images, function(err, uploadedImages) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log('Uploading images failed!');
|
winston.error('Uploading images failed!', err.stack);
|
||||||
} else {
|
} else {
|
||||||
postData.uploadedImages = JSON.stringify(uploadedImages);
|
postData.uploadedImages = JSON.stringify(uploadedImages);
|
||||||
Posts.setPostField(pid, 'uploadedImages', postData.uploadedImages);
|
Posts.setPostField(pid, 'uploadedImages', postData.uploadedImages);
|
||||||
|
|||||||
10
src/redis.js
10
src/redis.js
@@ -1,7 +1,8 @@
|
|||||||
(function(RedisDB) {
|
(function(RedisDB) {
|
||||||
var redis = require('redis'),
|
var redis = require('redis'),
|
||||||
nconf = require('nconf'),
|
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'));
|
RedisDB.exports = redis.createClient(nconf.get('redis:port'), nconf.get('redis:host'));
|
||||||
|
|
||||||
@@ -11,14 +12,9 @@
|
|||||||
|
|
||||||
RedisDB.exports.handle = function(error) {
|
RedisDB.exports.handle = function(error) {
|
||||||
if (error !== null) {
|
if (error !== null) {
|
||||||
|
winston.err(error);
|
||||||
if (global.env !== 'production') {
|
if (global.env !== 'production') {
|
||||||
console.log("################# ERROR LOG ####################");
|
|
||||||
console.log(error);
|
|
||||||
console.log(arguments.callee.name);
|
|
||||||
console.log("################# ERROR LOG ####################");
|
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
} else {
|
|
||||||
console.log(error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ var user = require('./../user.js'),
|
|||||||
finalData[key] = jsonObject[key];
|
finalData[key] = jsonObject[key];
|
||||||
}
|
}
|
||||||
} catch(err){
|
} 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) {
|
search(topicSearch, function(err, tids) {
|
||||||
if(err)
|
if(err)
|
||||||
return callback(err, null);
|
return callback(err, null);
|
||||||
console.log(tids);
|
|
||||||
topics.getTopicsByTids(tids, 0, function(topics) {
|
topics.getTopicsByTids(tids, 0, function(topics) {
|
||||||
callback(null, topics);
|
callback(null, topics);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
login_strategies = [],
|
login_strategies = [],
|
||||||
nconf = require('nconf'),
|
nconf = require('nconf'),
|
||||||
users = require('../user'),
|
users = require('../user'),
|
||||||
|
winston = require('winston'),
|
||||||
login_module = require('./../login.js');
|
login_module = require('./../login.js');
|
||||||
|
|
||||||
passport.use(new passportLocal(function(user, password, next) {
|
passport.use(new passportLocal(function(user, password, next) {
|
||||||
@@ -85,7 +86,7 @@
|
|||||||
|
|
||||||
app.get('/logout', function(req, res) {
|
app.get('/logout', function(req, res) {
|
||||||
if (req.user && req.user.uid > 0) {
|
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) {
|
login_module.logout(req.sessionID, function(logout) {
|
||||||
req.logout();
|
req.logout();
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({ req: req, res: res }, function(err, header) {
|
||||||
@@ -132,7 +133,6 @@
|
|||||||
|
|
||||||
app.get('/reset', function(req, res) {
|
app.get('/reset', function(req, res) {
|
||||||
app.build_header({ req: req, res: res }, function(err, header) {
|
app.build_header({ req: req, res: res }, function(err, header) {
|
||||||
console.log(header);
|
|
||||||
res.send(header + templates['reset'] + templates['footer']);
|
res.send(header + templates['reset'] + templates['footer']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ var user = require('./../user.js'),
|
|||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
utils = require('./../../public/src/utils.js'),
|
utils = require('./../../public/src/utils.js'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
marked = require('marked');
|
marked = require('marked'),
|
||||||
|
winston = require('winston');
|
||||||
|
|
||||||
(function(User) {
|
(function(User) {
|
||||||
User.create_routes = function(app) {
|
User.create_routes = function(app) {
|
||||||
@@ -136,7 +137,7 @@ var user = require('./../user.js'),
|
|||||||
|
|
||||||
fs.unlink(absolutePath, function(err) {
|
fs.unlink(absolutePath, function(err) {
|
||||||
if(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);
|
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 filename = uid + '-profileimg' + extension;
|
||||||
var uploadPath = path.join(global.configuration['ROOT_DIRECTORY'], global.nconf.get('upload_path'), filename);
|
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
|
winston.info('Attempting upload to: '+ uploadPath);
|
||||||
console.log('Info: Attempting upload to: '+ uploadPath);
|
|
||||||
|
|
||||||
var is = fs.createReadStream(tempPath);
|
var is = fs.createReadStream(tempPath);
|
||||||
var os = fs.createWriteStream(uploadPath);
|
var os = fs.createWriteStream(uploadPath);
|
||||||
@@ -176,11 +176,7 @@ var user = require('./../user.js'),
|
|||||||
height: 128
|
height: 128
|
||||||
}, function(err, stdout, stderr){
|
}, function(err, stdout, stderr){
|
||||||
if (err) {
|
if (err) {
|
||||||
// @todo: better logging method; for now, send to stderr.
|
winston.err(err.message, err.stack);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({ path: imageUrl });
|
res.json({ path: imageUrl });
|
||||||
@@ -189,7 +185,7 @@ var user = require('./../user.js'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
os.on('error', function(err) {
|
os.on('error', function(err) {
|
||||||
console.error('[%d] %s', Date.now(), + err);
|
winston.error('[%d] %s', Date.now(), + err);
|
||||||
});
|
});
|
||||||
|
|
||||||
is.pipe(os);
|
is.pipe(os);
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ var RDB = require('./redis.js'),
|
|||||||
notifications = require('./notifications.js'),
|
notifications = require('./notifications.js'),
|
||||||
posts = require('./posts'),
|
posts = require('./posts'),
|
||||||
reds = require('reds'),
|
reds = require('reds'),
|
||||||
topicSearch = reds.createSearch('nodebbtopicsearch');
|
topicSearch = reds.createSearch('nodebbtopicsearch'),
|
||||||
|
winston = require('winston');
|
||||||
|
|
||||||
(function(ThreadTools) {
|
(function(ThreadTools) {
|
||||||
|
|
||||||
@@ -192,7 +193,7 @@ var RDB = require('./redis.js'),
|
|||||||
|
|
||||||
categories.moveRecentReplies(tid, oldCid, cid, function(err, data) {
|
categories.moveRecentReplies(tid, oldCid, cid, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
winston.err(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
var RDB = require('./redis.js'),
|
var RDB = require('./redis.js'),
|
||||||
async = require('async');
|
async = require('async'),
|
||||||
|
winston = require('winston');
|
||||||
|
|
||||||
|
|
||||||
function upgradeCategory(cid, callback) {
|
function upgradeCategory(cid, callback) {
|
||||||
@@ -20,7 +20,6 @@ function upgradeCategory(cid, callback) {
|
|||||||
|
|
||||||
async.each(tids, moveTopic, function(err) {
|
async.each(tids, moveTopic, function(err) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
console.log('renaming ' + cid);
|
|
||||||
RDB.rename('temp_categories:' + cid + ':tid', 'categories:' + cid + ':tid');
|
RDB.rename('temp_categories:' + cid + ':tid', 'categories:' + cid + ':tid');
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
@@ -30,7 +29,7 @@ function upgradeCategory(cid, callback) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('category already upgraded '+ cid);
|
winston.info('category already upgraded '+ cid);
|
||||||
callback(null);
|
callback(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -52,33 +51,37 @@ function upgradeUser(uid, callback) {
|
|||||||
|
|
||||||
exports.upgrade = function() {
|
exports.upgrade = function() {
|
||||||
|
|
||||||
console.log('upgrading nodebb now');
|
winston.info('upgrading nodebb now');
|
||||||
|
|
||||||
var schema = [
|
var schema = [
|
||||||
function upgradeCategories(next) {
|
function upgradeCategories(next) {
|
||||||
console.log('upgrading categories');
|
winston.info('upgrading categories');
|
||||||
|
|
||||||
RDB.lrange('categories:cid', 0, -1, function(err, cids) {
|
RDB.lrange('categories:cid', 0, -1, function(err, cids) {
|
||||||
|
|
||||||
async.each(cids, upgradeCategory, function(err) {
|
async.each(cids, upgradeCategory, function(err) {
|
||||||
if(!err)
|
if(!err) {
|
||||||
next(null, 'upgraded categories');
|
winston.info('upgraded categories');
|
||||||
else
|
next(null, null);
|
||||||
|
} else {
|
||||||
next(err, null);
|
next(err, null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
function upgradeUsers(next) {
|
function upgradeUsers(next) {
|
||||||
console.log('upgrading users');
|
winston.info('upgrading users');
|
||||||
|
|
||||||
RDB.lrange('userlist', 0, -1, function(err, uids) {
|
RDB.lrange('userlist', 0, -1, function(err, uids) {
|
||||||
|
|
||||||
async.each(uids, upgradeUser, function(err) {
|
async.each(uids, upgradeUser, function(err) {
|
||||||
if(!err)
|
if(!err) {
|
||||||
next(null, 'upgraded users');
|
winston.info('upgraded users')
|
||||||
else
|
next(null, null);
|
||||||
|
} else {
|
||||||
next(err, null);
|
next(err, null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -87,9 +90,9 @@ exports.upgrade = function() {
|
|||||||
|
|
||||||
async.series(schema, function(err, results) {
|
async.series(schema, function(err, results) {
|
||||||
if(!err)
|
if(!err)
|
||||||
console.log('upgrade complete');
|
winston.info('upgrade complete');
|
||||||
else
|
else
|
||||||
console.log(err);
|
winston.err(err);
|
||||||
|
|
||||||
process.exit();
|
process.exit();
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ var express = require('express'),
|
|||||||
|
|
||||||
// respond with html page
|
// respond with html page
|
||||||
if (req.accepts('html')) {
|
if (req.accepts('html')) {
|
||||||
|
|
||||||
//res.json('404', { url: req.url });
|
//res.json('404', { url: req.url });
|
||||||
res.redirect(global.nconf.get('relative_path') + '/404');
|
res.redirect(global.nconf.get('relative_path') + '/404');
|
||||||
return;
|
return;
|
||||||
@@ -116,7 +115,6 @@ var express = require('express'),
|
|||||||
|
|
||||||
// respond with json
|
// respond with json
|
||||||
if (req.accepts('json')) {
|
if (req.accepts('json')) {
|
||||||
console.log('sending 404 json');
|
|
||||||
res.send({ error: 'Not found' });
|
res.send({ error: 'Not found' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
|||||||
'categories': require('./admin/categories.js'),
|
'categories': require('./admin/categories.js'),
|
||||||
'user': require('./admin/user.js')
|
'user': require('./admin/user.js')
|
||||||
},
|
},
|
||||||
plugins = require('./plugins');
|
plugins = require('./plugins'),
|
||||||
|
winston = require('winston');
|
||||||
|
|
||||||
(function(io) {
|
(function(io) {
|
||||||
var users = {},
|
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) {
|
user.getUsers(data.set, start, end, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log(err);
|
winston.err(err);
|
||||||
} else {
|
} else {
|
||||||
callback({users:data});
|
callback({users:data});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user