mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
refactor: 🔊 Fix duplicate logs
This commit is contained in:
parent
005a3a2721
commit
3e19b11609
|
|
@ -108,7 +108,7 @@ export default apiRoute((app) =>
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const error = e as ResponseError;
|
const error = e as ResponseError;
|
||||||
|
|
||||||
getLogger("federation")
|
getLogger(["federation", "bridge"])
|
||||||
.error`Error from bridge: ${await error.response.data}`;
|
.error`Error from bridge: ${await error.response.data}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ export class Instance extends BaseInterface<typeof Instances> {
|
||||||
} | null> {
|
} | null> {
|
||||||
const origin = new URL(url).origin;
|
const origin = new URL(url).origin;
|
||||||
const wellKnownUrl = new URL("/.well-known/versia", origin);
|
const wellKnownUrl = new URL("/.well-known/versia", origin);
|
||||||
const logger = getLogger("federation");
|
const logger = getLogger(["federation", "resolvers"]);
|
||||||
|
|
||||||
const requester = await User.getFederationRequester();
|
const requester = await User.getFederationRequester();
|
||||||
|
|
||||||
|
|
@ -201,7 +201,7 @@ export class Instance extends BaseInterface<typeof Instances> {
|
||||||
|
|
||||||
// Go to endpoint, then follow the links to the actual metadata
|
// Go to endpoint, then follow the links to the actual metadata
|
||||||
|
|
||||||
const logger = getLogger("federation");
|
const logger = getLogger(["federation", "resolvers"]);
|
||||||
const requester = await User.getFederationRequester();
|
const requester = await User.getFederationRequester();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -332,7 +332,7 @@ export class Instance extends BaseInterface<typeof Instances> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async resolve(url: string): Promise<Instance> {
|
public static async resolve(url: string): Promise<Instance> {
|
||||||
const logger = getLogger("federation");
|
const logger = getLogger(["federation", "resolvers"]);
|
||||||
const host = new URL(url).host;
|
const host = new URL(url).host;
|
||||||
|
|
||||||
const existingInstance = await Instance.fromSql(
|
const existingInstance = await Instance.fromSql(
|
||||||
|
|
@ -363,7 +363,7 @@ export class Instance extends BaseInterface<typeof Instances> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateFromRemote(): Promise<Instance> {
|
public async updateFromRemote(): Promise<Instance> {
|
||||||
const logger = getLogger("federation");
|
const logger = getLogger(["federation", "resolvers"]);
|
||||||
|
|
||||||
const output = await Instance.fetchMetadata(
|
const output = await Instance.fetchMetadata(
|
||||||
`https://${this.data.baseUrl}`,
|
`https://${this.data.baseUrl}`,
|
||||||
|
|
|
||||||
|
|
@ -747,7 +747,7 @@ export class Note extends BaseInterface<typeof Notes, NoteTypeWithRelations> {
|
||||||
author: User,
|
author: User,
|
||||||
): Promise<Note> {
|
): Promise<Note> {
|
||||||
const emojis: Emoji[] = [];
|
const emojis: Emoji[] = [];
|
||||||
const logger = getLogger("federation");
|
const logger = getLogger(["federation", "resolvers"]);
|
||||||
|
|
||||||
for (const emoji of note.extensions?.["pub.versia:custom_emojis"]
|
for (const emoji of note.extensions?.["pub.versia:custom_emojis"]
|
||||||
?.emojis ?? []) {
|
?.emojis ?? []) {
|
||||||
|
|
|
||||||
|
|
@ -716,7 +716,8 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async resolve(uri: string): Promise<User | null> {
|
public static async resolve(uri: string): Promise<User | null> {
|
||||||
getLogger("federation").debug`Resolving user ${chalk.gray(uri)}`;
|
getLogger(["federation", "resolvers"])
|
||||||
|
.debug`Resolving user ${chalk.gray(uri)}`;
|
||||||
// Check if user not already in database
|
// Check if user not already in database
|
||||||
const foundUser = await User.fromSql(eq(Users.uri, uri));
|
const foundUser = await User.fromSql(eq(Users.uri, uri));
|
||||||
|
|
||||||
|
|
@ -737,7 +738,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
||||||
return await User.fromId(uuid[0]);
|
return await User.fromId(uuid[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger("federation")
|
getLogger(["federation", "resolvers"])
|
||||||
.debug`User not found in database, fetching from remote`;
|
.debug`User not found in database, fetching from remote`;
|
||||||
|
|
||||||
return await User.saveFromRemote(uri);
|
return await User.saveFromRemote(uri);
|
||||||
|
|
@ -1014,9 +1015,9 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
getLogger("federation")
|
getLogger(["federation", "outbox"])
|
||||||
.error`Federating ${chalk.gray(entity.type)} to ${user.getUri()} ${chalk.bold.red("failed")}`;
|
.error`Federating ${chalk.gray(entity.type)} to ${user.getUri()} ${chalk.bold.red("failed")}`;
|
||||||
getLogger("federation").error`${e}`;
|
getLogger(["federation", "outbox"]).error`${e}`;
|
||||||
sentry?.captureException(e);
|
sentry?.captureException(e);
|
||||||
|
|
||||||
return { ok: false };
|
return { ok: false };
|
||||||
|
|
|
||||||
|
|
@ -175,12 +175,22 @@ export const configureLoggers = (silent = false): Promise<void> =>
|
||||||
filters: ["configFilter"],
|
filters: ["configFilter"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
category: "federation",
|
category: ["federation", "inbox"],
|
||||||
sinks: ["console", "file"],
|
sinks: ["console", "file"],
|
||||||
filters: ["configFilter"],
|
filters: ["configFilter"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
category: ["federation", "inbox"],
|
category: ["federation", "outbox"],
|
||||||
|
sinks: ["console", "file"],
|
||||||
|
filters: ["configFilter"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
category: ["federation", "bridge"],
|
||||||
|
sinks: ["console", "file"],
|
||||||
|
filters: ["configFilter"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
category: ["federation", "resolvers"],
|
||||||
sinks: ["console", "file"],
|
sinks: ["console", "file"],
|
||||||
filters: ["configFilter"],
|
filters: ["configFilter"],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue