diff --git a/packages/backend/src/boot/index.ts b/packages/backend/src/boot/index.ts index 489350a155..8caf7d062e 100644 --- a/packages/backend/src/boot/index.ts +++ b/packages/backend/src/boot/index.ts @@ -4,6 +4,7 @@ import Xev from "xev"; import Logger from "@/services/logger.js"; import { envOption } from "../env.js"; +import { inspect } from "node:util"; // for typeorm import "reflect-metadata"; @@ -82,7 +83,7 @@ if (!envOption.quiet) { // Display detail of uncaught exception process.on("uncaughtException", (err) => { try { - logger.error(err); + logger.error(inspect(err)); } catch {} }); diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index 4099629c44..9418f59e4c 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -13,6 +13,7 @@ import type { Config } from "@/config/types.js"; import { envOption } from "@/env.js"; import { showMachineInfo } from "@/misc/show-machine-info.js"; import { db, initDb } from "@/db/postgre.js"; +import { inspect } from "node:util"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); @@ -100,7 +101,7 @@ export async function masterMain() { await connectDb(); } catch (e) { bootLogger.error( - `Fatal error occurred during initialization: ${e}`, + `Fatal error occurred during initialization:\n${inspect(e)}`, null, true, ); @@ -182,15 +183,15 @@ async function connectDb(): Promise { // Try to connect to DB try { - dbLogger.info("Connecting..."); + dbLogger.info("Connecting to the database..."); await initDb(); const v = await db .query("SHOW server_version") .then((x) => x[0].server_version); dbLogger.succ(`Connected: v${v}`); } catch (e) { - dbLogger.error("Cannot connect", null, true); - dbLogger.error(e); + dbLogger.error("Failed to connect to the database", null, true); + dbLogger.error(inspect(e)); process.exit(1); } } diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 33b5826a7e..ab4c90b33e 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -4,10 +4,11 @@ import { EventEmitter } from "node:events"; import boot from "./boot/index.js"; +import { inspect } from "node:util"; Error.stackTraceLimit = Infinity; EventEmitter.defaultMaxListeners = 128; boot().catch((err) => { - console.error(err); + console.error(inspect(err)); }); diff --git a/packages/backend/src/misc/before-shutdown.ts b/packages/backend/src/misc/before-shutdown.ts index 0820418356..14b0afcd53 100644 --- a/packages/backend/src/misc/before-shutdown.ts +++ b/packages/backend/src/misc/before-shutdown.ts @@ -1,6 +1,7 @@ // https://gist.github.com/nfantone/1eaa803772025df69d07f4dbf5df7e58 "use strict"; +const inspect = require("node:util"); /** * @callback BeforeShutdownListener @@ -71,9 +72,7 @@ async function shutdownHandler(signalOrEvent: string) { } catch (err) { if (err instanceof Error) { console.warn( - `A shutdown handler failed before completing with: ${ - err.message || err - }`, + `A shutdown handler failed before completing with:\n${inspect(err)}`, ); } } diff --git a/packages/backend/src/misc/captcha.ts b/packages/backend/src/misc/captcha.ts index b3b3dca39d..c163d4d82d 100644 --- a/packages/backend/src/misc/captcha.ts +++ b/packages/backend/src/misc/captcha.ts @@ -2,6 +2,7 @@ import fetch from "node-fetch"; import { URLSearchParams } from "node:url"; import { getAgentByUrl } from "@/misc/fetch.js"; import config from "@/config/index.js"; +import { inspect } from "node:util"; export async function verifyRecaptcha(secret: string, response: string) { const result = await getCaptchaResponse( @@ -9,7 +10,7 @@ export async function verifyRecaptcha(secret: string, response: string) { secret, response, ).catch((e) => { - throw new Error(`recaptcha-request-failed: ${e.message}`); + throw new Error(`recaptcha-request-failed:\n${inspect(e)}`); }); if (result.success !== true) { @@ -26,7 +27,7 @@ export async function verifyHcaptcha(secret: string, response: string) { secret, response, ).catch((e) => { - throw new Error(`hcaptcha-request-failed: ${e.message}`); + throw new Error(`hcaptcha-request-failed:\n${inspect(e)}`); }); if (result.success !== true) { @@ -62,7 +63,7 @@ async function getCaptchaResponse( //timeout: 10 * 1000, agent: getAgentByUrl, }).catch((e) => { - throw new Error(`${e.message || e}`); + throw new Error(`${inspect(e)}`); }); if (!res.ok) { diff --git a/packages/backend/src/misc/emoji-meta.ts b/packages/backend/src/misc/emoji-meta.ts index 2b9365b826..539a034817 100644 --- a/packages/backend/src/misc/emoji-meta.ts +++ b/packages/backend/src/misc/emoji-meta.ts @@ -5,6 +5,7 @@ import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import Logger from "@/services/logger.js"; import { Cache } from "./cache.js"; import { redisClient } from "@/db/redis.js"; +import { inspect } from "node:util"; export type Size = { width: number; @@ -44,7 +45,7 @@ export async function getEmojiSize(url: string): Promise { } return { width, height }; } catch (e) { - throw new Error(`Unable to retrieve metadata: ${e}`); + throw new Error(`Unable to retrieve metadata:\n${inspect(e)}`); } } diff --git a/packages/backend/src/misc/get-file-info.ts b/packages/backend/src/misc/get-file-info.ts index 4195ed7aa4..dadbda9e9e 100644 --- a/packages/backend/src/misc/get-file-info.ts +++ b/packages/backend/src/misc/get-file-info.ts @@ -7,6 +7,7 @@ import probeImageSize from "probe-image-size"; import isSvg from "is-svg"; import sharp from "sharp"; import { encode } from "blurhash"; +import { inspect } from "node:util"; const pipeline = util.promisify(stream.pipeline); @@ -65,7 +66,7 @@ export async function getFileInfo(path: string): Promise { ].includes(type.mime) ) { const imageSize = await detectImageSize(path).catch((e) => { - warnings.push(`detectImageSize failed: ${e}`); + warnings.push(`detectImageSize failed:\n${inspect(e)}`); return undefined; }); @@ -102,7 +103,7 @@ export async function getFileInfo(path: string): Promise { ].includes(type.mime) ) { blurhash = await getBlurhash(path).catch((e) => { - warnings.push(`getBlurhash failed: ${e}`); + warnings.push(`getBlurhash failed:\n${inspect(e)}`); return undefined; }); } diff --git a/packages/backend/src/misc/i18n.ts b/packages/backend/src/misc/i18n.ts index 742bdb0f69..48c741f80e 100644 --- a/packages/backend/src/misc/i18n.ts +++ b/packages/backend/src/misc/i18n.ts @@ -21,7 +21,7 @@ export class I18n> { } } return str; - } catch (e) { + } catch { console.warn(`missing localization '${key}'`); return key; } diff --git a/packages/backend/src/misc/process-masto-notes.ts b/packages/backend/src/misc/process-masto-notes.ts index 1327b4cff0..03968944ec 100644 --- a/packages/backend/src/misc/process-masto-notes.ts +++ b/packages/backend/src/misc/process-masto-notes.ts @@ -8,6 +8,7 @@ import * as tar from "tar-stream"; import gunzip from "gunzip-maybe"; import decompress from "decompress"; import * as Path from "node:path"; +import { inspect } from "node:util"; const logger = new Logger("process-masto-notes"); @@ -103,7 +104,7 @@ function unzipZip(fn: string, dir: string) { function unzipTarGz(fn: string, dir: string) { return new Promise(async (resolve, reject) => { const onErr = (err: any) => { - logger.error(`pipe broken: ${err}`); + logger.error(`pipe broken:\n${inspect(err)}`); reject(); }; try { @@ -120,7 +121,7 @@ function unzipTarGz(fn: string, dir: string) { .on("error", onErr); next(); } catch (e) { - logger.error(`create dir error:${e}`); + logger.error(`create dir error:\n${inspect(e)}`); reject(); } }); @@ -136,7 +137,7 @@ function unzipTarGz(fn: string, dir: string) { .pipe(extract) .on("error", onErr); } catch (e) { - logger.error(`unzipTarGz error: ${e}`); + logger.error(`unzipTarGz error:\n${inspect(e)}`); reject(); } }); diff --git a/packages/backend/src/queue/processors/background/index-all-notes.ts b/packages/backend/src/queue/processors/background/index-all-notes.ts index 262724cbd6..115f2147b6 100644 --- a/packages/backend/src/queue/processors/background/index-all-notes.ts +++ b/packages/backend/src/queue/processors/background/index-all-notes.ts @@ -7,6 +7,7 @@ import { MoreThan } from "typeorm"; import { index } from "@/services/note/create.js"; import { Note } from "@/models/entities/note.js"; import meilisearch from "@/db/meilisearch.js"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("index-all-notes"); @@ -43,7 +44,7 @@ export default async function indexAllNotes( relations: ["user"], }); } catch (e: any) { - logger.error(`Failed to query notes ${e}`); + logger.error(`Failed to query notes:\n${inspect(e)}`); done(e); break; } diff --git a/packages/backend/src/queue/processors/db/export-custom-emojis.ts b/packages/backend/src/queue/processors/db/export-custom-emojis.ts index 86de43af42..a1ca3a91c5 100644 --- a/packages/backend/src/queue/processors/db/export-custom-emojis.ts +++ b/packages/backend/src/queue/processors/db/export-custom-emojis.ts @@ -11,6 +11,7 @@ import { createTemp, createTempDir } from "@/misc/create-temp.js"; import { downloadUrl } from "@/misc/download-url.js"; import config from "@/config/index.js"; import { IsNull } from "typeorm"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("export-custom-emojis"); @@ -76,7 +77,7 @@ export async function exportCustomEmojis( downloaded = true; } catch (e) { // TODO: 何度か再試行 - logger.error(e instanceof Error ? e : new Error(e as string)); + logger.error(inspect(e)); } if (!downloaded) { diff --git a/packages/backend/src/queue/processors/db/import-blocking.ts b/packages/backend/src/queue/processors/db/import-blocking.ts index 290c9dbceb..4d2732e32f 100644 --- a/packages/backend/src/queue/processors/db/import-blocking.ts +++ b/packages/backend/src/queue/processors/db/import-blocking.ts @@ -9,6 +9,7 @@ import { Users, DriveFiles } from "@/models/index.js"; import type { DbUserImportJobData } from "@/queue/types.js"; import block from "@/services/blocking/create.js"; import { IsNull } from "typeorm"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("import-blocking"); @@ -70,7 +71,7 @@ export async function importBlocking( await block(user, target); } catch (e) { - logger.warn(`Error in line:${linenum} ${e}`); + logger.warn(`Error in line ${linenum}:\n${inspect(e)}`); } } diff --git a/packages/backend/src/queue/processors/db/import-following.ts b/packages/backend/src/queue/processors/db/import-following.ts index b1a7cd2c9b..a08cf6c751 100644 --- a/packages/backend/src/queue/processors/db/import-following.ts +++ b/packages/backend/src/queue/processors/db/import-following.ts @@ -9,6 +9,7 @@ import { Users, DriveFiles } from "@/models/index.js"; import type { DbUserImportJobData } from "@/queue/types.js"; import { queueLogger } from "../../logger.js"; import type Bull from "bull"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("import-following"); @@ -68,7 +69,7 @@ export async function importFollowing( follow(user, target); } catch (e) { - logger.warn(`Error in line:${linenum} ${e}`); + logger.warn(`Error in line ${linenum}:\n${inspect(e)}`); } } } else { @@ -106,7 +107,7 @@ export async function importFollowing( follow(user, target); } catch (e) { - logger.warn(`Error in line:${linenum} ${e}`); + logger.warn(`Error in line ${linenum}:\n${inspect(e)}`); } } } diff --git a/packages/backend/src/queue/processors/db/import-muting.ts b/packages/backend/src/queue/processors/db/import-muting.ts index 80e0567397..8a378ef6ab 100644 --- a/packages/backend/src/queue/processors/db/import-muting.ts +++ b/packages/backend/src/queue/processors/db/import-muting.ts @@ -10,6 +10,7 @@ import type { DbUserImportJobData } from "@/queue/types.js"; import type { User } from "@/models/entities/user.js"; import { genId } from "@/misc/gen-id.js"; import { IsNull } from "typeorm"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("import-muting"); @@ -71,7 +72,7 @@ export async function importMuting( await mute(user, target); } catch (e) { - logger.warn(`Error in line:${linenum} ${e}`); + logger.warn(`Error in line ${linenum}: ${inspect(e)}`); } } diff --git a/packages/backend/src/queue/processors/db/import-posts.ts b/packages/backend/src/queue/processors/db/import-posts.ts index 526489c634..eee74bddeb 100644 --- a/packages/backend/src/queue/processors/db/import-posts.ts +++ b/packages/backend/src/queue/processors/db/import-posts.ts @@ -8,6 +8,7 @@ import { createImportCkPostJob, createImportMastoPostJob, } from "@/queue/index.js"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("import-posts"); @@ -44,7 +45,7 @@ export async function importPosts( } } catch (e) { // handle error - logger.warn(`Failed reading Mastodon archive: ${e}`); + logger.warn(`Failed to read Mastodon archive:\n${inspect(e)}`); } logger.succ("Mastodon archive imported"); done(); @@ -69,7 +70,7 @@ export async function importPosts( } } catch (e) { // handle error - logger.warn(`Error reading: ${e}`); + logger.warn(`Error occured while reading:\n${inspect(e)}`); } logger.succ("Imported"); diff --git a/packages/backend/src/queue/processors/db/import-user-lists.ts b/packages/backend/src/queue/processors/db/import-user-lists.ts index 0c23f06991..886c316041 100644 --- a/packages/backend/src/queue/processors/db/import-user-lists.ts +++ b/packages/backend/src/queue/processors/db/import-user-lists.ts @@ -15,6 +15,7 @@ import { import { genId } from "@/misc/gen-id.js"; import type { DbUserImportJobData } from "@/queue/types.js"; import { IsNull } from "typeorm"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("import-user-lists"); @@ -87,7 +88,7 @@ export async function importUserLists( pushUserToUserList(target, list!); } catch (e) { - logger.warn(`Error in line:${linenum} ${e}`); + logger.warn(`Error in line ${linenum}:\n${inspect(e)}`); } } diff --git a/packages/backend/src/queue/processors/inbox.ts b/packages/backend/src/queue/processors/inbox.ts index 116f279ac3..54364d1a72 100644 --- a/packages/backend/src/queue/processors/inbox.ts +++ b/packages/backend/src/queue/processors/inbox.ts @@ -23,6 +23,7 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; import type { UserPublickey } from "@/models/entities/user-publickey.js"; import { shouldBlockInstance } from "@/misc/should-block-instance.js"; import { verifySignature } from "@/remote/activitypub/check-fetch.js"; +import { inspect } from "node:util"; const logger = new Logger("inbox"); @@ -78,9 +79,7 @@ export default async (job: Bull.Job): Promise => { if (e.isClientError) { return `skip: Ignored deleted actors on both ends ${activity.actor} - ${e.statusCode}`; } - throw new Error( - `Error in actor ${activity.actor} - ${e.statusCode || e}`, - ); + throw new Error(`Error in actor ${activity.actor}\n${inspect(e)}`); } } } diff --git a/packages/backend/src/queue/processors/system/local-emoji-size.ts b/packages/backend/src/queue/processors/system/local-emoji-size.ts index d696bbd863..73595ed77b 100644 --- a/packages/backend/src/queue/processors/system/local-emoji-size.ts +++ b/packages/backend/src/queue/processors/system/local-emoji-size.ts @@ -4,6 +4,7 @@ import { Emojis } from "@/models/index.js"; import { queueLogger } from "../../logger.js"; import { getEmojiSize } from "@/misc/emoji-meta.js"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("local-emoji-size"); @@ -27,7 +28,7 @@ export async function setLocalEmojiSizes( }); } catch (e) { logger.error( - `Unable to set emoji size (${i + 1}/${emojis.length}): ${e}`, + `Unable to set emoji size (${i + 1}/${emojis.length}):\n${inspect(e)}`, ); /* skip if any error happens */ } finally { diff --git a/packages/backend/src/queue/processors/system/verify-links.ts b/packages/backend/src/queue/processors/system/verify-links.ts index 4ee88c6310..230e55de52 100644 --- a/packages/backend/src/queue/processors/system/verify-links.ts +++ b/packages/backend/src/queue/processors/system/verify-links.ts @@ -4,6 +4,7 @@ import { UserProfiles } from "@/models/index.js"; import { Not } from "typeorm"; import { queueLogger } from "../../logger.js"; import { verifyLink } from "@/services/fetch-rel-me.js"; +import { inspect } from "node:util"; const logger = queueLogger.createSubLogger("verify-links"); @@ -32,7 +33,7 @@ export async function verifyLinks( fields: user.fields, }); } catch (e) { - logger.error(`Failed to update user ${user.userId} ${e}`); + logger.error(`Failed to update user ${user.userId}:\n${inspect(e)}`); done(e); } } diff --git a/packages/backend/src/remote/activitypub/deliver-manager.ts b/packages/backend/src/remote/activitypub/deliver-manager.ts index c97d1c99ae..c4f8ca2069 100644 --- a/packages/backend/src/remote/activitypub/deliver-manager.ts +++ b/packages/backend/src/remote/activitypub/deliver-manager.ts @@ -3,6 +3,8 @@ import { Users, Followings } from "@/models/index.js"; import type { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js"; import { deliver } from "@/queue/index.js"; import { skippedInstances } from "@/misc/skipped-instances.js"; +import { apLogger } from "./logger"; +import { inspect } from "node:util"; //#region types interface IRecipe { @@ -131,8 +133,7 @@ export default class DeliverManager { host: new URL(inbox).host, }); } catch (error) { - console.error(error); - console.error(`Invalid Inbox ${inbox}`); + apLogger.error(`Invalid Inbox ${inbox}:\n${inspect(error)}`); } } diff --git a/packages/backend/src/remote/activitypub/kernel/accept/index.ts b/packages/backend/src/remote/activitypub/kernel/accept/index.ts index 5c73760ff3..bb03bf9a62 100644 --- a/packages/backend/src/remote/activitypub/kernel/accept/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/accept/index.ts @@ -4,6 +4,7 @@ import acceptFollow from "./follow.js"; import type { IAccept } from "../../type.js"; import { isFollow, getApType } from "../../type.js"; import { apLogger } from "../../logger.js"; +import { inspect } from "node:util"; const logger = apLogger; @@ -18,7 +19,7 @@ export default async ( const resolver = new Resolver(); const object = await resolver.resolve(activity.object).catch((e) => { - logger.error(`Resolution failed: ${e}`); + logger.error(`Resolution failed:\n${inspect(e)}`); throw e; }); diff --git a/packages/backend/src/remote/activitypub/kernel/announce/note.ts b/packages/backend/src/remote/activitypub/kernel/announce/note.ts index 50b59932cf..cc33b681eb 100644 --- a/packages/backend/src/remote/activitypub/kernel/announce/note.ts +++ b/packages/backend/src/remote/activitypub/kernel/announce/note.ts @@ -11,6 +11,7 @@ import { parseAudience } from "../../audience.js"; import { StatusError } from "@/misc/fetch.js"; import { Notes } from "@/models/index.js"; import { shouldBlockInstance } from "@/misc/should-block-instance.js"; +import { inspect } from "node:util"; const logger = apLogger; @@ -53,9 +54,7 @@ export default async function ( return; } - logger.warn( - `Error in announce target ${targetUri} - ${e.statusCode || e}`, - ); + logger.warn(`Error in announce target ${targetUri}:\n${inspect(e)}`); } throw e; } diff --git a/packages/backend/src/remote/activitypub/kernel/create/index.ts b/packages/backend/src/remote/activitypub/kernel/create/index.ts index 3dcf648247..d3bc1936d5 100644 --- a/packages/backend/src/remote/activitypub/kernel/create/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/create/index.ts @@ -5,6 +5,7 @@ import type { ICreate } from "../../type.js"; import { getApId, isPost, getApType } from "../../type.js"; import { apLogger } from "../../logger.js"; import { toArray, concat, unique } from "@/prelude/array.js"; +import { inspect } from "node:util"; const logger = apLogger; @@ -39,7 +40,7 @@ export default async ( const resolver = new Resolver(); const object = await resolver.resolve(activity.object).catch((e) => { - logger.error(`Resolution failed: ${e}`); + logger.error(`Resolution failed:\n${inspect(e)}`); throw e; }); diff --git a/packages/backend/src/remote/activitypub/kernel/index.ts b/packages/backend/src/remote/activitypub/kernel/index.ts index a90ac02345..aa99f6c320 100644 --- a/packages/backend/src/remote/activitypub/kernel/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/index.ts @@ -40,6 +40,7 @@ import move from "./move/index.js"; import type { IObject, IActivity } from "../type.js"; import { extractDbHost } from "@/misc/convert-host.js"; import { shouldBlockInstance } from "@/misc/should-block-instance.js"; +import { inspect } from "node:util"; export async function performActivity( actor: CacheableRemoteUser, @@ -54,9 +55,7 @@ export async function performActivity( try { await performOneActivity(actor, act); } catch (err) { - if (err instanceof Error || typeof err === "string") { - apLogger.error(err); - } + apLogger.error(inspect(err)); } } } else { @@ -90,9 +89,9 @@ async function performOneActivity( } else if (isReject(activity)) { await reject(actor, activity); } else if (isAdd(activity)) { - await add(actor, activity).catch((err) => apLogger.error(err)); + await add(actor, activity).catch((err) => apLogger.error(inspect(err))); } else if (isRemove(activity)) { - await remove(actor, activity).catch((err) => apLogger.error(err)); + await remove(actor, activity).catch((err) => apLogger.error(inspect(err))); } else if (isAnnounce(activity)) { await announce(actor, activity); } else if (isLike(activity)) { diff --git a/packages/backend/src/remote/activitypub/kernel/reject/index.ts b/packages/backend/src/remote/activitypub/kernel/reject/index.ts index 10edb0f7a2..001231d030 100644 --- a/packages/backend/src/remote/activitypub/kernel/reject/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/reject/index.ts @@ -4,6 +4,7 @@ import rejectFollow from "./follow.js"; import type { IReject } from "../../type.js"; import { isFollow, getApType } from "../../type.js"; import { apLogger } from "../../logger.js"; +import { inspect } from "node:util"; const logger = apLogger; @@ -18,7 +19,7 @@ export default async ( const resolver = new Resolver(); const object = await resolver.resolve(activity.object).catch((e) => { - logger.error(`Resolution failed: ${e}`); + logger.error(`Resolution failed:\n${inspect(e)}`); throw e; }); diff --git a/packages/backend/src/remote/activitypub/kernel/undo/index.ts b/packages/backend/src/remote/activitypub/kernel/undo/index.ts index f0e2316fab..c1c18271f9 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/index.ts @@ -15,6 +15,7 @@ import undoAccept from "./accept.js"; import { undoAnnounce } from "./announce.js"; import Resolver from "../../resolver.js"; import { apLogger } from "../../logger.js"; +import { inspect } from "node:util"; const logger = apLogger; @@ -33,7 +34,7 @@ export default async ( const resolver = new Resolver(); const object = await resolver.resolve(activity.object).catch((e) => { - logger.error(`Resolution failed: ${e}`); + logger.error(`Resolution failed:\n${inspect(e)}`); throw e; }); diff --git a/packages/backend/src/remote/activitypub/kernel/update/index.ts b/packages/backend/src/remote/activitypub/kernel/update/index.ts index 558a20ce0f..933f2c99e0 100644 --- a/packages/backend/src/remote/activitypub/kernel/update/index.ts +++ b/packages/backend/src/remote/activitypub/kernel/update/index.ts @@ -5,6 +5,7 @@ import { apLogger } from "../../logger.js"; import { updateNote } from "../../models/note.js"; import Resolver from "../../resolver.js"; import { updatePerson } from "../../models/person.js"; +import { inspect } from "node:util"; /** * Handler for the Update activity @@ -22,7 +23,7 @@ export default async ( const resolver = new Resolver(); const object = await resolver.resolve(activity.object).catch((e) => { - apLogger.error(`Resolution failed: ${e}`); + apLogger.error(`Resolution failed:\n${inspect(e)}`); throw e; }); diff --git a/packages/backend/src/remote/activitypub/models/note.ts b/packages/backend/src/remote/activitypub/models/note.ts index fb617953e5..19b8fe49e7 100644 --- a/packages/backend/src/remote/activitypub/models/note.ts +++ b/packages/backend/src/remote/activitypub/models/note.ts @@ -50,6 +50,7 @@ import { DB_MAX_IMAGE_COMMENT_LENGTH } from "@/misc/hard-limits.js"; import { truncate } from "@/misc/truncate.js"; import { type Size, getEmojiSize } from "@/misc/emoji-meta.js"; import { langmap } from "@/misc/langmap.js"; +import { inspect } from "node:util"; const logger = apLogger; @@ -242,9 +243,7 @@ export async function createNote( } } - logger.warn( - `Error in inReplyTo ${note.inReplyTo} - ${e.statusCode || e}`, - ); + logger.warn(`Error in inReplyTo ${note.inReplyTo}:\n${inspect(e)}`); throw e; }) : null; @@ -359,7 +358,7 @@ export async function createNote( } const emojis = await extractEmojis(note.tag || [], actor.host).catch((e) => { - logger.info(`extractEmojis: ${e}`); + logger.info(`extractEmojis:\n${inspect(e)}`); return [] as Emoji[]; }); diff --git a/packages/backend/src/remote/activitypub/models/person.ts b/packages/backend/src/remote/activitypub/models/person.ts index 9030d3d904..72bcc15c44 100644 --- a/packages/backend/src/remote/activitypub/models/person.ts +++ b/packages/backend/src/remote/activitypub/models/person.ts @@ -47,6 +47,7 @@ import Resolver from "../resolver.js"; import { extractApHashtags } from "./tag.js"; import { resolveNote, extractEmojis } from "./note.js"; import { resolveImage } from "./image.js"; +import { inspect } from "node:util"; const logger = apLogger; @@ -349,7 +350,7 @@ export async function createPerson( throw new Error("already registered"); } } else { - logger.error(e instanceof Error ? e : new Error(e as string)); + logger.error(inspect(e)); throw e; } } @@ -389,7 +390,7 @@ export async function createPerson( //#region Get custom emoji const emojis = await extractEmojis(person.tag || [], host).catch((e) => { - logger.info(`extractEmojis: ${e}`); + logger.info(`extractEmojis:\n${inspect(e)}`); return [] as Emoji[]; }); @@ -400,7 +401,9 @@ export async function createPerson( }); //#endregion - await updateFeatured(user!.id, resolver).catch((err) => logger.error(err)); + await updateFeatured(user!.id, resolver).catch((err) => + logger.error(inspect(err)), + ); return user!; } @@ -451,7 +454,7 @@ export async function updatePerson( // Custom pictogram acquisition const emojis = await extractEmojis(person.tag || [], user.host).catch((e) => { - logger.info(`extractEmojis: ${e}`); + logger.info(`extractEmojis:\n${inspect(e)}`); return [] as Emoji[]; }); @@ -617,7 +620,9 @@ export async function updatePerson( }, ); - await updateFeatured(user.id, resolver).catch((err) => logger.error(err)); + await updateFeatured(user.id, resolver).catch((err) => + logger.error(inspect(err)), + ); } /** diff --git a/packages/backend/src/remote/resolve-user.ts b/packages/backend/src/remote/resolve-user.ts index a6c1e399a5..f73b670273 100644 --- a/packages/backend/src/remote/resolve-user.ts +++ b/packages/backend/src/remote/resolve-user.ts @@ -8,6 +8,7 @@ import { toPuny } from "@/misc/convert-host.js"; import webFinger from "./webfinger.js"; import { createPerson, updatePerson } from "./activitypub/models/person.js"; import { remoteLogger } from "./logger.js"; +import { inspect } from "node:util"; const logger = remoteLogger.createSubLogger("resolve-user"); @@ -118,9 +119,7 @@ async function resolveSelf(acctLower: string) { logger.info(`WebFinger for ${chalk.yellow(acctLower)}`); const finger = await webFinger(acctLower).catch((e) => { logger.error( - `Failed to WebFinger for ${chalk.yellow(acctLower)}: ${ - e.statusCode || e.message - }`, + `Failed to WebFinger for ${chalk.yellow(acctLower)}:\n${inspect(e)}`, ); throw new Error( `Failed to WebFinger for ${acctLower}: ${e.statusCode || e.message}`, diff --git a/packages/backend/src/server/activitypub.ts b/packages/backend/src/server/activitypub.ts index 660db98e48..7c437d3d6d 100644 --- a/packages/backend/src/server/activitypub.ts +++ b/packages/backend/src/server/activitypub.ts @@ -58,7 +58,7 @@ function inbox(ctx: Router.RouterContext) { headers: ["(request-target)", "digest", "host", "date"], }); } catch (e) { - serverLogger.warn(`inbox: signature parse error: ${inspect(e)}`); + serverLogger.warn(`inbox: signature parse error:\n${inspect(e)}`); ctx.status = 401; if (e instanceof Error) { diff --git a/packages/backend/src/server/api/endpoints/drive/files/create.ts b/packages/backend/src/server/api/endpoints/drive/files/create.ts index b4a345306b..a3e3fafa2f 100644 --- a/packages/backend/src/server/api/endpoints/drive/files/create.ts +++ b/packages/backend/src/server/api/endpoints/drive/files/create.ts @@ -7,6 +7,7 @@ import { MINUTE } from "@/const.js"; import define from "@/server/api/define.js"; import { apiLogger } from "@/server/api/logger.js"; import { ApiError } from "@/server/api/error.js"; +import { inspect } from "node:util"; export const meta = { tags: ["drive"], @@ -112,9 +113,8 @@ export default define( }); return await DriveFiles.pack(driveFile, { self: true }); } catch (e) { - if (e instanceof Error || typeof e === "string") { - apiLogger.error(e); - } + if (typeof e === "string") apiLogger.error(e); + if (e instanceof Error) apiLogger.error(inspect(e)); if (e instanceof IdentifiableError) { if (e.id === "282f77bf-5816-4f72-9264-aa14d8261a21") throw new ApiError(meta.errors.inappropriate); diff --git a/packages/backend/src/server/api/endpoints/i/known-as.ts b/packages/backend/src/server/api/endpoints/i/known-as.ts index 39bf6fff83..070d6d7f00 100644 --- a/packages/backend/src/server/api/endpoints/i/known-as.ts +++ b/packages/backend/src/server/api/endpoints/i/known-as.ts @@ -9,6 +9,7 @@ import { apiLogger } from "@/server/api/logger.js"; import define from "@/server/api/define.js"; import { ApiError } from "@/server/api/error.js"; import { parse } from "@/misc/acct.js"; +import { inspect } from "node:util"; export const meta = { tags: ["users"], @@ -74,7 +75,7 @@ export default define(meta, paramDef, async (ps, user) => { const { username, host } = parse(line); const aka = await resolveUser(username, host).catch((e) => { - apiLogger.warn(`failed to resolve remote user: ${e}`); + apiLogger.warn(`failed to resolve remote user:\n${inspect(e)}`); throw new ApiError(meta.errors.noSuchUser); }); diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts index c6d1205f98..6bd76a621d 100644 --- a/packages/backend/src/server/api/endpoints/i/move.ts +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -13,6 +13,7 @@ import { Followings, Users } from "@/models/index.js"; import config from "@/config/index.js"; import { publishMainStream } from "@/services/stream.js"; import { parse } from "@/misc/acct.js"; +import { inspect } from "node:util"; export const meta = { tags: ["users"], @@ -99,7 +100,7 @@ export default define(meta, paramDef, async (ps, user) => { if (!host) throw new ApiError(meta.errors.notRemote); const moveTo: User = await resolveUser(username, host).catch((e) => { - apiLogger.warn(`failed to resolve remote user: ${e}`); + apiLogger.warn(`failed to resolve remote user:\n${inspect(e)}`); throw new ApiError(meta.errors.noSuchMoveTarget); }); let fromUrl: string | null = user.uri; diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index 1eb55a77e0..1bb8ad4939 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -22,8 +22,10 @@ import signupPending from "./private/signup-pending.js"; import verifyEmail from "./private/verify-email.js"; import { koaBody } from "koa-body"; import { convertAttachment } from "./mastodon/converters.js"; +import { apiLogger } from "./logger.js"; import { convertId, IdConvertType as IdType } from "backend-rs"; +import { inspect } from "node:util"; // re-export native rust id conversion (function and enum) export { IdType, convertId }; @@ -90,7 +92,7 @@ mastoFileRouter.post("/v1/media", upload.single("file"), async (ctx) => { const data = await client.uploadMedia(multipartData); ctx.body = convertAttachment(data.data as Entity.Attachment); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -109,7 +111,7 @@ mastoFileRouter.post("/v2/media", upload.single("file"), async (ctx) => { const data = await client.uploadMedia(multipartData, ctx.request.body); ctx.body = convertAttachment(data.data as Entity.Attachment); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts index e029bc604e..ec3600537c 100644 --- a/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts +++ b/packages/backend/src/server/api/mastodon/ApiMastodonCompatibleService.ts @@ -16,6 +16,8 @@ import { import { convertId, IdType } from "@/server/api/index.js"; import { Users } from "@/models/index.js"; import { IsNull } from "typeorm"; +import { apiLogger } from "../logger.js"; +import { inspect } from "node:util"; export function getClient( BASE_URL: string, @@ -45,7 +47,7 @@ export function apiMastodonCompatible(router: Router): void { const data = await client.getInstanceCustomEmojis(); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -73,7 +75,7 @@ export function apiMastodonCompatible(router: Router): void { : convertAccount((await client.getAccount(admin.id)).data); ctx.body = await getInstance(data.data, contact); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -89,7 +91,7 @@ export function apiMastodonCompatible(router: Router): void { convertAnnouncement(announcement), ); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -107,7 +109,7 @@ export function apiMastodonCompatible(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -123,7 +125,7 @@ export function apiMastodonCompatible(router: Router): void { const data = await client.getFilters(); ctx.body = data.data.map((filter) => convertFilter(filter)); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -138,7 +140,7 @@ export function apiMastodonCompatible(router: Router): void { const data = await client.getInstanceTrends(); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -153,7 +155,7 @@ export function apiMastodonCompatible(router: Router): void { const data = await client.getPreferences(); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/account.ts b/packages/backend/src/server/api/mastodon/endpoints/account.ts index 76c3af378d..a6f953677c 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/account.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/account.ts @@ -9,6 +9,8 @@ import { convertRelationship, convertStatus, } from "../converters.js"; +import { apiLogger } from "../../logger.js"; +import { inspect } from "node:util"; const relationshipModel = { id: "", @@ -52,8 +54,7 @@ export function apiAccountMastodon(router: Router): void { console.log(acct); ctx.body = acct; } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -68,8 +69,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertAccount(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -85,8 +85,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertAccount(data.data.accounts[0]); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -119,10 +118,9 @@ export function apiAccountMastodon(router: Router): void { convertRelationship(relationship), ); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); let data = e.response.data; data.users = users; - console.error(data); ctx.status = 401; ctx.body = data; } @@ -136,8 +134,7 @@ export function apiAccountMastodon(router: Router): void { const data = await client.getAccount(calcId); ctx.body = convertAccount(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -155,8 +152,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -174,8 +170,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((tag) => convertFeaturedTag(tag)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -194,8 +189,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -214,8 +208,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -233,8 +226,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((list) => convertList(list)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -254,8 +246,7 @@ export function apiAccountMastodon(router: Router): void { acct.following = true; ctx.body = acct; } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -275,8 +266,7 @@ export function apiAccountMastodon(router: Router): void { acct.following = false; ctx.body = acct; } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -294,8 +284,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertRelationship(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -313,8 +302,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertRelationship(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -333,8 +321,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertRelationship(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -352,8 +339,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertRelationship(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -367,8 +353,7 @@ export function apiAccountMastodon(router: Router): void { const data = await client.getFeaturedTags(); ctx.body = data.data.map((tag) => convertFeaturedTag(tag)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -381,8 +366,7 @@ export function apiAccountMastodon(router: Router): void { const data = await client.getFollowedTags(); ctx.body = data.data; } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -397,8 +381,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -413,8 +396,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -429,8 +411,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -445,8 +426,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -461,8 +441,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -479,8 +458,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertRelationship(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -498,8 +476,7 @@ export function apiAccountMastodon(router: Router): void { ); ctx.body = convertRelationship(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/auth.ts b/packages/backend/src/server/api/mastodon/endpoints/auth.ts index 3c7ece920a..e65e310b14 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/auth.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/auth.ts @@ -1,5 +1,7 @@ import Router from "@koa/router"; import { getClient } from "../ApiMastodonCompatibleService.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { inspect } from "node:util"; const readScope = [ "read:account", @@ -70,7 +72,7 @@ export function apiAuthMastodon(router: Router): void { console.log(returns); ctx.body = returns; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/filter.ts b/packages/backend/src/server/api/mastodon/endpoints/filter.ts index 6524fd2f6e..30fb1e1eab 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/filter.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/filter.ts @@ -2,6 +2,8 @@ import Router from "@koa/router"; import { getClient } from "../ApiMastodonCompatibleService.js"; import { IdType, convertId } from "@/server/api/index.js"; import { convertFilter } from "../converters.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { inspect } from "node:util"; export function apiFilterMastodon(router: Router): void { router.get("/v1/filters", async (ctx) => { @@ -13,7 +15,7 @@ export function apiFilterMastodon(router: Router): void { const data = await client.getFilters(); ctx.body = data.data.map((filter) => convertFilter(filter)); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -30,7 +32,7 @@ export function apiFilterMastodon(router: Router): void { ); ctx.body = convertFilter(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -45,7 +47,7 @@ export function apiFilterMastodon(router: Router): void { const data = await client.createFilter(body.phrase, body.context, body); ctx.body = convertFilter(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -64,7 +66,7 @@ export function apiFilterMastodon(router: Router): void { ); ctx.body = convertFilter(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -81,7 +83,7 @@ export function apiFilterMastodon(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/notifications.ts b/packages/backend/src/server/api/mastodon/endpoints/notifications.ts index 9628eccdde..3df740a91e 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/notifications.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/notifications.ts @@ -3,6 +3,9 @@ import { convertId, IdType } from "@/server/api/index.js"; import { getClient } from "../ApiMastodonCompatibleService.js"; import { convertTimelinesArgsId } from "./timeline.js"; import { convertNotification } from "../converters.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { inspect } from "node:util"; + function toLimitToInt(q: any) { if (q.limit) if (typeof q.limit === "string") q.limit = parseInt(q.limit, 10); return q; @@ -30,7 +33,7 @@ export function apiNotificationsMastodon(router: Router): void { }); ctx.body = ret; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -55,7 +58,7 @@ export function apiNotificationsMastodon(router: Router): void { data.type = "favourite"; } } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -70,7 +73,7 @@ export function apiNotificationsMastodon(router: Router): void { const data = await client.dismissNotifications(); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -87,7 +90,7 @@ export function apiNotificationsMastodon(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/search.ts b/packages/backend/src/server/api/mastodon/endpoints/search.ts index c9bbab0a4f..533a1f5e1c 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/search.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/search.ts @@ -4,6 +4,8 @@ import axios from "axios"; import { Converter } from "megalodon"; import { convertTimelinesArgsId, limitToInt } from "./timeline.js"; import { convertAccount, convertStatus } from "../converters.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { inspect } from "node:util"; export function apiSearchMastodon(router: Router): void { router.get("/v1/search", async (ctx) => { @@ -17,7 +19,7 @@ export function apiSearchMastodon(router: Router): void { const data = await client.search(query.q, type, query); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -50,7 +52,7 @@ export function apiSearchMastodon(router: Router): void { hashtags: tags?.data?.hashtags ?? [], }; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -66,7 +68,7 @@ export function apiSearchMastodon(router: Router): void { ); ctx.body = data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -89,7 +91,7 @@ export function apiSearchMastodon(router: Router): void { console.log(data); ctx.body = data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -109,8 +111,7 @@ async function getHighlight( const data: MisskeyEntity.Note[] = api.data; return data.map((note) => new Converter(BASE_URL).note(note, domain)); } catch (e: any) { - console.log(e); - console.log(e.response.data); + apiLogger.info(inspect(e)); return []; } } @@ -131,7 +132,7 @@ async function getFeaturedUser( state: "alive", }); const data: MisskeyEntity.UserDetail[] = api.data; - console.log(data); + apiLogger.info(inspect(data)); return data.map((u) => { return { source: "past_interactions", @@ -139,8 +140,7 @@ async function getFeaturedUser( }; }); } catch (e: any) { - console.log(e); - console.log(e.response.data); + apiLogger.info(inspect(e)); return []; } } diff --git a/packages/backend/src/server/api/mastodon/endpoints/status.ts b/packages/backend/src/server/api/mastodon/endpoints/status.ts index ac1cbe602d..33201d9edf 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/status.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/status.ts @@ -12,6 +12,8 @@ import { convertStatus, } from "../converters.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { inspect } from "node:util"; function normalizeQuery(data: any) { const str = querystring.stringify(data); @@ -54,7 +56,7 @@ export function apiStatusMastodon(router: Router): void { const data = await client.deleteEmojiReaction(id, react); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -91,7 +93,7 @@ export function apiStatusMastodon(router: Router): void { const data = await client.postStatus(text, body); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -106,7 +108,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = ctx.status == 404 ? 404 : 401; ctx.body = e.response.data; } @@ -121,7 +123,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e.response.data, request.params.id); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -153,7 +155,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -171,7 +173,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -189,7 +191,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -207,7 +209,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -229,8 +231,7 @@ export function apiStatusMastodon(router: Router): void { //const data = await client.favouriteStatus(ctx.params.id) as any; ctx.body = convertStatus(a.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -251,7 +252,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -270,7 +271,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -289,7 +290,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -308,7 +309,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -327,7 +328,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -346,7 +347,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -365,7 +366,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -385,7 +386,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -405,7 +406,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertStatus(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -422,7 +423,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertAttachment(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -438,7 +439,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertAttachment(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -453,7 +454,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertPoll(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -471,7 +472,7 @@ export function apiStatusMastodon(router: Router): void { ); ctx.body = convertPoll(data.data); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts index 05741c4cef..9d29ef3f7a 100644 --- a/packages/backend/src/server/api/mastodon/endpoints/timeline.ts +++ b/packages/backend/src/server/api/mastodon/endpoints/timeline.ts @@ -8,6 +8,8 @@ import { convertStatus, } from "../converters.js"; import { convertId, IdType } from "@/server/api/index.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { inspect } from "node:util"; export function limitToInt(q: ParsedUrlQuery) { let object: any = q; @@ -71,8 +73,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -90,8 +91,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -107,8 +107,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -126,8 +125,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data.map((status) => convertStatus(status)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -145,8 +143,7 @@ export function apiTimelineMastodon(router: Router): void { convertConversation(conversation), ); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -159,8 +156,7 @@ export function apiTimelineMastodon(router: Router): void { const data = await client.getLists(); ctx.body = data.data.map((list) => convertList(list)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -177,8 +173,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = convertList(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -192,8 +187,7 @@ export function apiTimelineMastodon(router: Router): void { const data = await client.createList((ctx.request.body as any).title); ctx.body = convertList(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -211,8 +205,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = convertList(data.data); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -230,8 +223,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -250,8 +242,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data.map((account) => convertAccount(account)); } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -272,8 +263,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } @@ -294,8 +284,7 @@ export function apiTimelineMastodon(router: Router): void { ); ctx.body = data.data; } catch (e: any) { - console.error(e); - console.error(e.response.data); + apiLogger.error(inspect(e)); ctx.status = 401; ctx.body = e.response.data; } diff --git a/packages/backend/src/server/api/private/signup.ts b/packages/backend/src/server/api/private/signup.ts index d60e5a1910..ba6d23d28f 100644 --- a/packages/backend/src/server/api/private/signup.ts +++ b/packages/backend/src/server/api/private/signup.ts @@ -9,6 +9,7 @@ import { sendEmail } from "@/services/send-email.js"; import { genId } from "@/misc/gen-id.js"; import { validateEmailForAccount } from "@/services/validate-email-for-account.js"; import { hashPassword } from "@/misc/password.js"; +import { inspect } from "node:util"; export default async (ctx: Koa.Context) => { const body = ctx.request.body; diff --git a/packages/backend/src/server/api/stream/index.ts b/packages/backend/src/server/api/stream/index.ts index 86408a03d0..071bcb8da1 100644 --- a/packages/backend/src/server/api/stream/index.ts +++ b/packages/backend/src/server/api/stream/index.ts @@ -27,6 +27,8 @@ import type Channel from "./channel.js"; import type { StreamEventEmitter, StreamMessages } from "./types.js"; import { Converter } from "megalodon"; import { getClient } from "@/server/api/mastodon/ApiMastodonCompatibleService.js"; +import { apiLogger } from "@/server/api/logger.js"; +import { inspect } from "node:util"; /** * Main stream connection @@ -183,7 +185,7 @@ export default class Connection { const tl = await client.getHomeTimeline(); for (const t of tl.data) forSubscribe.push(t.id); } catch (e: any) { - console.error(e); + apiLogger.error(inspect(e)); } } else if (simpleObj.stream === "public:local") { this.currentSubscribe.push(["public:local"]); diff --git a/packages/backend/src/server/file/send-drive-file.ts b/packages/backend/src/server/file/send-drive-file.ts index 090ea35027..e7aaf78dcb 100644 --- a/packages/backend/src/server/file/send-drive-file.ts +++ b/packages/backend/src/server/file/send-drive-file.ts @@ -16,6 +16,7 @@ import { GenerateVideoThumbnail } from "@/services/drive/generate-video-thumbnai import { StatusError } from "@/misc/fetch.js"; import { ByteRangeReadable } from "./byte-range-readable.js"; import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; +import { inspect } from "node:util"; const _filename = fileURLToPath(import.meta.url); const _dirname = dirname(_filename); @@ -106,7 +107,7 @@ export default async function (ctx: Koa.Context) { ); ctx.set("Cache-Control", "max-age=31536000, immutable"); } catch (e) { - serverLogger.error(`${e}`); + serverLogger.error(`${inspect(e)}`); if (e instanceof StatusError && e.isClientError) { ctx.status = e.statusCode; diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 3a9f62f337..00ad0baef9 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -33,6 +33,7 @@ import { initializeStreamingServer } from "./api/streaming.js"; import { koaBody } from "koa-body"; import removeTrailingSlash from "koa-remove-trailing-slashes"; import { v4 as uuid } from "uuid"; +import { inspect } from "node:util"; export const serverLogger = new Logger("server", "gray", false); @@ -194,10 +195,10 @@ mastoRouter.post("/oauth/token", async (ctx) => { scope: body.scope || "read write follow push", created_at: Math.floor(new Date().getTime() / 1000), }; - console.log("token-response", ret); + serverLogger.info("token-response", ret); ctx.body = ret; } catch (err: any) { - console.error(err); + serverLogger.error(inspect(err)); ctx.status = 401; ctx.body = err.response.data; } diff --git a/packages/backend/src/server/proxy/proxy-media.ts b/packages/backend/src/server/proxy/proxy-media.ts index ed607daa0e..a505d74a0f 100644 --- a/packages/backend/src/server/proxy/proxy-media.ts +++ b/packages/backend/src/server/proxy/proxy-media.ts @@ -12,6 +12,7 @@ import { StatusError } from "@/misc/fetch.js"; import { FILE_TYPE_BROWSERSAFE } from "@/const.js"; import { serverLogger } from "../index.js"; import { isMimeImage } from "@/misc/is-mime-image.js"; +import { inspect } from "node:util"; export async function proxyMedia(ctx: Koa.Context) { let url = "url" in ctx.query ? ctx.query.url : `https://${ctx.params.url}`; @@ -130,7 +131,7 @@ export async function proxyMedia(ctx: Koa.Context) { ctx.set("Cache-Control", "max-age=31536000, immutable"); ctx.body = image.data; } catch (e) { - serverLogger.error(`${e}`); + serverLogger.error(`${inspect(e)}`); if (e instanceof StatusError && (e.statusCode === 302 || e.isClientError)) { ctx.status = e.statusCode; diff --git a/packages/backend/src/server/web/url-preview.ts b/packages/backend/src/server/web/url-preview.ts index c9f3b6cac9..9b32cabab1 100644 --- a/packages/backend/src/server/web/url-preview.ts +++ b/packages/backend/src/server/web/url-preview.ts @@ -5,6 +5,7 @@ import Logger from "@/services/logger.js"; import config from "@/config/index.js"; import { query } from "@/prelude/url.js"; import { getJson } from "@/misc/fetch.js"; +import { inspect } from "node:util"; const logger = new Logger("url-preview"); @@ -69,7 +70,7 @@ export const urlPreviewHandler = async (ctx: Koa.Context) => { ctx.body = summary; } catch (err) { - logger.warn(`Failed to get preview of ${url}: ${err}`); + logger.warn(`Failed to get preview of ${url}:\n${inspect(err)}`); ctx.status = 200; ctx.set("Cache-Control", "max-age=86400, immutable"); ctx.body = "{}"; diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index b9a66bcd26..73869f1d44 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -33,6 +33,7 @@ import { convertSharpToWebp } from "./image-processor.js"; import { driveLogger } from "./logger.js"; import { GenerateVideoThumbnail } from "./generate-video-thumbnail.js"; import { deleteFile } from "./delete-file.js"; +import { inspect } from "node:util"; const logger = driveLogger.createSubLogger("register", "yellow"); @@ -234,7 +235,7 @@ export async function generateAlts( thumbnail, }; } catch (err) { - logger.warn(`GenerateVideoThumbnail failed: ${err}`); + logger.warn(`GenerateVideoThumbnail failed:\n${inspect(err)}`); return { webpublic: null, thumbnail: null, @@ -289,7 +290,7 @@ export async function generateAlts( metadata.height <= 2048 ); } catch (err) { - logger.warn(`sharp failed: ${err}`); + logger.warn(`sharp failed:\n${inspect(err)}`); return { webpublic: null, thumbnail: null, @@ -315,7 +316,7 @@ export async function generateAlts( logger.debug("web image not created (not an required image)"); } } catch (err) { - logger.warn("web image not created (an error occured)", err as Error); + logger.warn(`web image not created (an error occured):\n${inspect(err)}`); } } else { if (satisfyWebpublic) @@ -342,7 +343,7 @@ export async function generateAlts( logger.debug("thumbnail not created (not an required file)"); } } catch (err) { - logger.warn("thumbnail not created (an error occured)", err as Error); + logger.warn(`thumbnail not created (an error occured):\n${inspect(err)}`); } // #endregion thumbnail @@ -629,7 +630,7 @@ export async function addFile({ userId: user ? user.id : IsNull(), })) as DriveFile; } else { - logger.error(err as Error); + logger.error(inspect(err)); throw err; } } diff --git a/packages/backend/src/services/drive/s3.ts b/packages/backend/src/services/drive/s3.ts index d01f89cbbf..8886309222 100644 --- a/packages/backend/src/services/drive/s3.ts +++ b/packages/backend/src/services/drive/s3.ts @@ -2,6 +2,7 @@ import { URL } from "node:url"; import S3 from "aws-sdk/clients/s3.js"; // TODO: migrate to SDK v3 import type { Meta } from "@/models/entities/meta.js"; import { getAgentByUrl } from "@/misc/fetch.js"; +import { inspect } from "node:util"; export function getS3(meta: Meta) { const u = @@ -27,7 +28,7 @@ export function getS3(meta: Meta) { }); } catch (e) { throw new Error( - `Failed to construct S3 client, assembled S3 URL: ${u}\n${e}`, + `Failed to construct S3 client, assembled S3 URL: ${u}\n${inspect(e)}`, ); } } diff --git a/packages/backend/src/services/drive/upload-from-url.ts b/packages/backend/src/services/drive/upload-from-url.ts index adbeee5a82..551d3757ca 100644 --- a/packages/backend/src/services/drive/upload-from-url.ts +++ b/packages/backend/src/services/drive/upload-from-url.ts @@ -7,6 +7,7 @@ import type { DriveFile } from "@/models/entities/drive-file.js"; import { DriveFiles } from "@/models/index.js"; import { driveLogger } from "./logger.js"; import { addFile } from "./add-file.js"; +import { inspect } from "node:util"; const logger = driveLogger.createSubLogger("downloader"); @@ -78,10 +79,7 @@ export async function uploadFromUrl({ logger.succ(`Got: ${driveFile.id}`); return driveFile!; } catch (e) { - logger.error(`Failed to create drive file: ${e}`, { - url: url, - e: e, - }); + logger.error(`Failed to create drive file:\n${inspect(e)}`); throw e; } finally { cleanup(); diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index a4cc33bca5..6795db0690 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -7,6 +7,7 @@ import type { Instance } from "@/models/entities/instance.js"; import { Instances } from "@/models/index.js"; import { getFetchInstanceMetadataLock } from "@/misc/app-lock.js"; import Logger from "@/services/logger.js"; +import { inspect } from "node:util"; const logger = new Logger("metadata", "cyan"); @@ -77,7 +78,9 @@ export async function fetchInstanceMetadata( logger.succ(`Successfuly updated metadata of ${instance.host}`); } catch (e) { - logger.error(`Failed to update metadata of ${instance.host}: ${e}`); + logger.error( + `Failed to update metadata of ${instance.host}:\n${inspect(e)}`, + ); } finally { await lock.release(); } @@ -111,7 +114,7 @@ async function fetchNodeinfo(instance: Instance): Promise { if (e.statusCode === 404) { throw new Error("No nodeinfo provided"); } else { - throw new Error(e.statusCode || e.message); + throw new Error(inspect(e)); } })) as Record; @@ -137,14 +140,16 @@ async function fetchNodeinfo(instance: Instance): Promise { } const info = await getJson(link.href).catch((e) => { - throw new Error(e.statusCode || e.message); + throw new Error(inspect(e)); }); logger.succ(`Successfuly fetched nodeinfo of ${instance.host}`); return info as NodeInfo; } catch (e) { - logger.error(`Failed to fetch nodeinfo of ${instance.host}: ${e.message}`); + logger.error( + `Failed to fetch nodeinfo of ${instance.host}:\n${inspect(e)}`, + ); throw e; } diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 6edf5f2ec2..16fab4b689 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -68,6 +68,10 @@ import meilisearch from "@/db/meilisearch.js"; import { redisClient } from "@/db/redis.js"; import { Mutex } from "redis-semaphore"; import { langmap } from "@/misc/langmap.js"; +import Logger from "@/services/logger.js"; +import { inspect } from "node:util"; + +const logger = new Logger("create-note"); const mutedWordsCache = new Cache< { userId: UserProfile["userId"]; mutedWords: UserProfile["mutedWords"] }[] @@ -814,7 +818,7 @@ async function insertNote( throw err; } - console.error(e); + logger.error(inspect(e)); throw e; } diff --git a/packages/backend/src/services/send-email.ts b/packages/backend/src/services/send-email.ts index ccc6b365d9..fcc93c79fb 100644 --- a/packages/backend/src/services/send-email.ts +++ b/packages/backend/src/services/send-email.ts @@ -2,6 +2,7 @@ import * as nodemailer from "nodemailer"; import { fetchMeta } from "@/misc/fetch-meta.js"; import Logger from "@/services/logger.js"; import config from "@/config/index.js"; +import { inspect } from "node:util"; export const logger = new Logger("email"); @@ -67,7 +68,7 @@ export async function sendEmail( logger.info(`Message sent: ${info.messageId}`); } catch (err) { - logger.error(err as Error); + logger.error(inspect(err)); throw err; } } diff --git a/packages/client/src/components/MkVisibilityPicker.vue b/packages/client/src/components/MkVisibilityPicker.vue index 7f7eac52c4..16746d7376 100644 --- a/packages/client/src/components/MkVisibilityPicker.vue +++ b/packages/client/src/components/MkVisibilityPicker.vue @@ -95,9 +95,7 @@
- {{ - i18n.ts.private - }} + {{ i18n.ts.private }} {{ i18n.ts.privateDescription }}