Skip to content

Commit

Permalink
fix(logs): Reduce amount of logging in production (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienjoly committed Sep 6, 2020
1 parent 85b3f07 commit 4b5efce
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/invites.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ exports.handleRequest = function (request, reqParams, response) {
null,
{ 'content-type': 'text/html' }
);
console.log('rendering done!');
// console.log('rendering done!');
},
{ sort: [['date', 'desc']] }
);
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/collabPl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports.controller = function (request, reqParams, response) {

function render(html) {
response.renderHTML(html);
console.log('rendering done!');
// console.log('rendering done!');
if (
loggedInUser &&
loggedInUser.id &&
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/pgApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ exports.controller = function (request, reqParams, response) {
});
if (data.html) {
response.renderHTML(data.html);
console.log('rendering done!');
// console.log('rendering done!');
//if (loggedInUser && loggedInUser.id && !reqParams.after && !reqParams.before)
// analytics.addVisit(loggedInUser, request.url/*"/u/"+uid*/);
} else response.legacyRender(data.text || data.json || data.error);
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/pgGenre.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ exports.controller = function (request, reqParams, response) {
if (data.error) console.log('ERROR: ', data.error);
if (data.html) {
response.renderHTML(data.html);
console.log('rendering done!');
// console.log('rendering done!');
//if (loggedInUser && loggedInUser.id && !reqParams.after && !reqParams.before)
// analytics.addVisit(loggedInUser, request.url/*"/u/"+uid*/);
} else response.legacyRender(data.json || data.error);
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/recentActivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ exports.controller = function (request, reqParams, response) {

function render(html) {
response.legacyRender(html, null, { 'content-type': 'text/html' });
console.log('rendering done!');
// console.log('rendering done!');
if (
loggedInUser &&
loggedInUser.id &&
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/userLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ exports.controller = function (request, reqParams, response) {
);
} else if (data.html) {
response.renderHTML(data.html);
console.log('rendering done!');
// console.log('rendering done!');
if (
loggedInUser &&
loggedInUser.id &&
Expand Down
5 changes: 1 addition & 4 deletions app/models/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ exports.addVisit = function (uId, tId, request) {
else if (orig.includes('http')) orig = null;
}

console.log('analytics.addVisit ', uId, tId, orig);

var visit = { uId: uId, tId: tId };
var visit = { uId, tId };
if (orig) visit.orig = orig;

//mongodb.collections["visit"].insertOne(visit, {w:0}); // disabled write concern
visit._t = new Date().getTime();
visitStream.write(JSON.stringify(visit) + '\n');
};
2 changes: 1 addition & 1 deletion app/models/searchMongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ exports.topicNameSearch = function (
//console.log(renderTemplate(q,results));
//response.legacyRender(util.inspect(results));
resultHandler(results, q);
console.log('search: rendering done!');
// console.log('search: rendering done!');
}
};
var timeout = setTimeout(renderer, timeoutDuration);
Expand Down
9 changes: 8 additions & 1 deletion app/models/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,14 @@ exports.snapshotTrackScores = function (cb) {
mongodb.forEach2('track', { fields: { score: 1 } }, function (track, next) {
if (!track) cb();
else {
console.log('snapshotTrackScores', ++i, '/', count);
if (count < 1000) {
console.log(`snapshotTrackScores ${i + 1} / ${count}`);
} else if (count % 1000 === 0) {
console.log(
`snapshotTrackScores ${i / 1000}k / ${Math.floor(count / 1000)}k`
);
}
++i;
mongodb.collections['track'].update(
{ _id: track._id },
{ $set: { prev: track.score } },
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function processUsers(list) {
}

function fetch(q, handler) {
snip.console.log('fetching user ', q, '...');
// snip.console.log('fetching user ', q, '...');
if (q._id && typeof q._id == 'string') q._id = ObjectId(q._id);
mongodb.collections['user'].findOne(q, function (err, user) {
if (user) {
Expand Down
2 changes: 1 addition & 1 deletion app/templates/mainTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ exports.renderWhydPage = function (params = {}) {
].concat(params.css || []);

var user = params.loggedUser || {};
console.log('connected user:', user.name, user.id);
// console.log('connected user:', user.name, user.id);

// other recognized params: bodyClass, head, content, sidebar

Expand Down
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ fi

# Start new server
echo "🌄 Starting Openwhyd with WHYD_PORT=$PORT..."
cd $ROOT_DIR && source env-vars-local.sh && WHYD_PORT=$PORT npm run forever:start &
cd $ROOT_DIR && source env-vars-local.sh && WHYD_PORT=$PORT npm run forever:start -- --no-color &

# TODO: find a way to identify that instance, e.g. -- "--uid openwhyd_$PORT"

0 comments on commit 4b5efce

Please sign in to comment.