get rid of some verbose logs, switch to ap.helpers.log

This commit is contained in:
Barış Soner Uşaklı
2026-03-12 10:58:55 -04:00
parent 894248e60d
commit 73eb0bffe7
6 changed files with 13 additions and 13 deletions

View File

@@ -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);
}
};

View File

@@ -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;
}

View File

@@ -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]]`);

View File

@@ -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.`);
}
}
};

View File

@@ -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({

View File

@@ -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);