From 02c3ee12dcdc7187e83436c2d435cede6ce2eccb Mon Sep 17 00:00:00 2001 From: cuteBoiButt Date: Thu, 5 Sep 2024 17:29:03 +0000 Subject: [PATCH 1/2] Use proper logging facilities in WebfingerService --- packages/backend/src/core/WebfingerService.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/WebfingerService.ts b/packages/backend/src/core/WebfingerService.ts index 1517dd0074..86079a115b 100644 --- a/packages/backend/src/core/WebfingerService.ts +++ b/packages/backend/src/core/WebfingerService.ts @@ -8,6 +8,8 @@ import { Injectable } from '@nestjs/common'; import { XMLParser } from 'fast-xml-parser'; import { HttpRequestService } from '@/core/HttpRequestService.js'; import { bindThis } from '@/decorators.js'; +import Logger from '@/logger.js'; +import { RemoteLoggerService } from './RemoteLoggerService.js'; export type ILink = { href: string; @@ -28,9 +30,13 @@ const defaultProtocol = process.env.MISSKEY_WEBFINGER_USE_HTTP?.toLowerCase() == @Injectable() export class WebfingerService { + private logger: Logger; + constructor( private httpRequestService: HttpRequestService, + private remoteLoggerService: RemoteLoggerService, ) { + this.logger = this.remoteLoggerService.logger.createSubLogger('webfinger'); } @bindThis @@ -103,7 +109,7 @@ export class WebfingerService { const template = (hostMeta['XRD']['Link'] as Array).filter(p => p['@_rel'] === 'lrdd')[0]['@_template']; return template.indexOf('{uri}') < 0 ? null : template; } catch (err) { - console.error(`error while request host-meta for ${url}: ${err}`); + this.logger.error(`error while request host-meta for ${url}: ${err}`); return null; } } From 6b88c4f143716544b49817c0d93e2b972ede9edf Mon Sep 17 00:00:00 2001 From: cuteBoiButt Date: Fri, 6 Sep 2024 11:45:00 +0000 Subject: [PATCH 2/2] We don't need the whole Logger class here --- packages/backend/src/core/WebfingerService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/core/WebfingerService.ts b/packages/backend/src/core/WebfingerService.ts index 86079a115b..f57e7a2c1f 100644 --- a/packages/backend/src/core/WebfingerService.ts +++ b/packages/backend/src/core/WebfingerService.ts @@ -8,7 +8,7 @@ import { Injectable } from '@nestjs/common'; import { XMLParser } from 'fast-xml-parser'; import { HttpRequestService } from '@/core/HttpRequestService.js'; import { bindThis } from '@/decorators.js'; -import Logger from '@/logger.js'; +import type Logger from '@/logger.js'; import { RemoteLoggerService } from './RemoteLoggerService.js'; export type ILink = {