mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Refactor debugging and logging more
This commit is contained in:
parent
82c6dc17a8
commit
ab6fe6988c
20 changed files with 230 additions and 123 deletions
|
|
@ -35,6 +35,8 @@ import {
|
|||
statusToMentions,
|
||||
user,
|
||||
} from "~drizzle/schema";
|
||||
import { dualLogger } from "@loggers";
|
||||
import { LogLevel } from "~packages/log-manager";
|
||||
import type { Note } from "~types/lysand/Object";
|
||||
import type { Attachment as APIAttachment } from "~types/mastodon/attachment";
|
||||
import type { Status as APIStatus } from "~types/mastodon/status";
|
||||
|
|
@ -601,7 +603,11 @@ export const resolveStatus = async (
|
|||
for (const attachment of note.attachments ?? []) {
|
||||
const resolvedAttachment = await attachmentFromLysand(attachment).catch(
|
||||
(e) => {
|
||||
console.error(e);
|
||||
dualLogger.logError(
|
||||
LogLevel.ERROR,
|
||||
"Federation.StatusResolver",
|
||||
e,
|
||||
);
|
||||
return null;
|
||||
},
|
||||
);
|
||||
|
|
@ -616,7 +622,7 @@ export const resolveStatus = async (
|
|||
for (const emoji of note.extensions?.["org.lysand:custom_emojis"]?.emojis ??
|
||||
[]) {
|
||||
const resolvedEmoji = await fetchEmoji(emoji).catch((e) => {
|
||||
console.error(e);
|
||||
dualLogger.logError(LogLevel.ERROR, "Federation.StatusResolver", e);
|
||||
return null;
|
||||
});
|
||||
|
||||
|
|
@ -1010,8 +1016,14 @@ export const federateStatus = async (status: StatusWithRelations) => {
|
|||
const response = await fetch(request);
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(await response.text());
|
||||
throw new Error(
|
||||
dualLogger.log(
|
||||
LogLevel.DEBUG,
|
||||
"Federation.Status",
|
||||
await response.text(),
|
||||
);
|
||||
dualLogger.log(
|
||||
LogLevel.ERROR,
|
||||
"Federation.Status",
|
||||
`Failed to federate status ${status.id} to ${user.uri}`,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import {
|
|||
relationship,
|
||||
user,
|
||||
} from "~drizzle/schema";
|
||||
import { dualLogger } from "@loggers";
|
||||
import { LogLevel } from "~packages/log-manager";
|
||||
import type { Account as APIAccount } from "~types/mastodon/account";
|
||||
import type { Source as APISource } from "~types/mastodon/source";
|
||||
import {
|
||||
|
|
@ -191,8 +193,15 @@ export const followRequestUser = async (
|
|||
const response = await fetch(request);
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(await response.text());
|
||||
console.error(
|
||||
dualLogger.log(
|
||||
LogLevel.DEBUG,
|
||||
"Federation.FollowRequest",
|
||||
await response.text(),
|
||||
);
|
||||
|
||||
dualLogger.log(
|
||||
LogLevel.ERROR,
|
||||
"Federation.FollowRequest",
|
||||
`Failed to federate follow request from ${follower.id} to ${followee.uri}`,
|
||||
);
|
||||
|
||||
|
|
@ -230,8 +239,15 @@ export const sendFollowAccept = async (follower: User, followee: User) => {
|
|||
const response = await fetch(request);
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(await response.text());
|
||||
throw new Error(
|
||||
dualLogger.log(
|
||||
LogLevel.DEBUG,
|
||||
"Federation.FollowAccept",
|
||||
await response.text(),
|
||||
);
|
||||
|
||||
dualLogger.log(
|
||||
LogLevel.ERROR,
|
||||
"Federation.FollowAccept",
|
||||
`Failed to federate follow accept from ${followee.id} to ${follower.uri}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -249,8 +265,15 @@ export const sendFollowReject = async (follower: User, followee: User) => {
|
|||
const response = await fetch(request);
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(await response.text());
|
||||
throw new Error(
|
||||
dualLogger.log(
|
||||
LogLevel.DEBUG,
|
||||
"Federation.FollowReject",
|
||||
await response.text(),
|
||||
);
|
||||
|
||||
dualLogger.log(
|
||||
LogLevel.ERROR,
|
||||
"Federation.FollowReject",
|
||||
`Failed to federate follow reject from ${followee.id} to ${follower.uri}`,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue