mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-18 02:20:49 +01:00
get rid of some verbose logs, switch to ap.helpers.log
This commit is contained in:
@@ -42,11 +42,11 @@ Helpers._test = (method, args) => {
|
||||
let _lastLog;
|
||||
Helpers.log = (message) => {
|
||||
if (!message) {
|
||||
return _lastLog;
|
||||
return _lastLog || 'run in development mode to see last log';
|
||||
}
|
||||
|
||||
_lastLog = message;
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
_lastLog = message;
|
||||
winston.verbose(message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -449,7 +449,7 @@ inbox.announce = async (req) => {
|
||||
if (!fromRelay && !cid && !syncedCids.length) {
|
||||
const { followers } = await activitypub.actors.getLocalFollowCounts(actor);
|
||||
if (!followers) {
|
||||
winston.verbose(`[activitypub/inbox.announce] Rejecting ${object.id} via ${actor} due to no followers`);
|
||||
activitypub.helpers.log(`[activitypub/inbox.announce] Rejecting ${object.id} via ${actor} due to no followers`);
|
||||
reject('Announce', object, actor);
|
||||
return;
|
||||
}
|
||||
@@ -635,7 +635,7 @@ inbox.undo = async (req) => {
|
||||
|
||||
let { type: localType, id } = await helpers.resolveLocalId(object.object);
|
||||
|
||||
winston.verbose(`[activitypub/inbox/undo] ${type} ${localType && id ? `${localType} ${id}` : object.object} via ${actor}`);
|
||||
activitypub.helpers.log(`[activitypub/inbox/undo] ${type} ${localType && id ? `${localType} ${id}` : object.object} via ${actor}`);
|
||||
|
||||
switch (type) {
|
||||
case 'Follow': {
|
||||
@@ -680,7 +680,7 @@ inbox.undo = async (req) => {
|
||||
|
||||
const allowed = await privileges.posts.can('posts:upvote', id, activitypub._constants.uid);
|
||||
if (!allowed) {
|
||||
winston.verbose(`[activitypub/inbox.like] ${id} not allowed to be upvoted.`);
|
||||
activitypub.helpers.log(`[activitypub/inbox.like] ${id} not allowed to be upvoted.`);
|
||||
reject('Like', object, actor);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -338,9 +338,9 @@ ActivityPub.get = async (type, id, uri, options) => {
|
||||
});
|
||||
|
||||
if (!String(response.statusCode).startsWith('2')) {
|
||||
winston.verbose(`[activitypub/get] Received ${response.statusCode} when querying ${uri}`);
|
||||
ActivityPub.helpers.log(`[activitypub/get] Received ${response.statusCode} when querying ${uri}`);
|
||||
if (body.hasOwnProperty('error')) {
|
||||
winston.verbose(`[activitypub/get] Error received: ${body.error}`);
|
||||
ActivityPub.helpers.log(`[activitypub/get] Error received: ${body.error}`);
|
||||
}
|
||||
|
||||
const e = new Error(`[[error:activitypub.get-failed]]`);
|
||||
|
||||
@@ -318,7 +318,7 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
|
||||
winston.warn(`[activitypub/notes.assert] Could not assert ${id} (${e.message}).`);
|
||||
return null;
|
||||
} finally {
|
||||
winston.verbose(`[activitypub/notes.assert] Releasing lock (${id})`);
|
||||
activitypub.helpers.log(`[activitypub/notes.assert] Releasing lock (${id})`);
|
||||
await db.deleteObjectField('locks', id);
|
||||
}
|
||||
};
|
||||
@@ -563,7 +563,7 @@ Notes.getParentChain = async (uid, input) => {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
winston.verbose(`[activitypub/notes/getParentChain] Cannot retrieve ${id}, terminating here.`);
|
||||
activitypub.helpers.log(`[activitypub/notes/getParentChain] Cannot retrieve ${id}, terminating here.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs/promises');
|
||||
const nconf = require('nconf');
|
||||
const winston = require('winston');
|
||||
const { default: satori } = require('satori');
|
||||
const sharp = require('sharp');
|
||||
|
||||
@@ -33,14 +32,12 @@ Icons.get = async (cid) => {
|
||||
};
|
||||
|
||||
Icons.flush = async (cid) => {
|
||||
winston.verbose(`[categories/icons] Flushing ${cid}.`);
|
||||
const paths = Icons._constants.extensions.map(extension => path.resolve(nconf.get('upload_path'), 'category', `category-${cid}-icon.${extension}`));
|
||||
|
||||
await Promise.all(paths.map((async path => await fs.rm(path, { force: true }))));
|
||||
};
|
||||
|
||||
Icons.regenerate = async (cid) => {
|
||||
winston.verbose(`[categories/icons] Regenerating ${cid}.`);
|
||||
const { icon, color, bgColor } = await categories.getCategoryData(cid);
|
||||
|
||||
const fontPaths = new Map(Object.entries({
|
||||
|
||||
@@ -10,6 +10,7 @@ const plugins = require('../plugins');
|
||||
const translator = require('../translator');
|
||||
const utils = require('../utils');
|
||||
const postCache = require('./cache');
|
||||
const devMode = process.env.NODE_ENV === 'development';
|
||||
|
||||
let sanitizeConfig = {
|
||||
allowedTags: sanitize.defaults.allowedTags.concat([
|
||||
@@ -99,7 +100,9 @@ module.exports = function (Posts) {
|
||||
content.slice(current.index + offset + current[1].length);
|
||||
}
|
||||
} catch (err) {
|
||||
winston.verbose(err.messsage);
|
||||
if (devMode) {
|
||||
winston.verbose(err.messsage);
|
||||
}
|
||||
}
|
||||
}
|
||||
current = regex.exec(content);
|
||||
|
||||
Reference in New Issue
Block a user