change logger

This commit is contained in:
tamaina 2024-03-05 05:49:12 +00:00
parent ac4336db43
commit 6e4357c378
1 changed files with 12 additions and 5 deletions

View File

@ -13,8 +13,9 @@ import { bindThis } from '@/decorators.js';
import type { IActivity } from '@/core/activitypub/type.js'; import type { IActivity } from '@/core/activitypub/type.js';
import { ThinUser } from '@/queue/types.js'; import { ThinUser } from '@/queue/types.js';
import { AccountUpdateService } from '@/core/AccountUpdateService.js'; import { AccountUpdateService } from '@/core/AccountUpdateService.js';
import type Logger from '@/logger.js';
import { UserKeypairService } from '../UserKeypairService.js'; import { UserKeypairService } from '../UserKeypairService.js';
import Logger from '@/logger.js'; import { ApLoggerService } from './ApLoggerService.js';
interface IRecipe { interface IRecipe {
type: string; type: string;
@ -24,8 +25,6 @@ interface IFollowersRecipe extends IRecipe {
type: 'Followers'; type: 'Followers';
} }
const logger = new Logger('deliver-manager', 'azure');
interface IDirectRecipe extends IRecipe { interface IDirectRecipe extends IRecipe {
type: 'Direct'; type: 'Direct';
to: MiRemoteUser; to: MiRemoteUser;
@ -55,6 +54,7 @@ class DeliverManager {
private followingsRepository: FollowingsRepository, private followingsRepository: FollowingsRepository,
private queueService: QueueService, private queueService: QueueService,
private accountUpdateService: AccountUpdateService, private accountUpdateService: AccountUpdateService,
private logger: Logger,
actor: { id: MiUser['id']; host: null; }, actor: { id: MiUser['id']; host: null; },
activity: IActivity | null, activity: IActivity | null,
@ -117,7 +117,7 @@ class DeliverManager {
*/ */
const created = await this.userKeypairService.refreshAndprepareEd25519KeyPair(this.actor.id); const created = await this.userKeypairService.refreshAndprepareEd25519KeyPair(this.actor.id);
if (created) { if (created) {
logger.info(`ed25519 key pair created for user ${this.actor.id} and publishing to followers`); this.logger.info(`ed25519 key pair created for user ${this.actor.id} and publishing to followers`);
// リモートに配信 // リモートに配信
await this.accountUpdateService.publishToFollowers(this.actor.id, true); await this.accountUpdateService.publishToFollowers(this.actor.id, true);
} }
@ -164,12 +164,14 @@ class DeliverManager {
// deliver // deliver
await this.queueService.deliverMany(this.actor, this.activity, inboxes); await this.queueService.deliverMany(this.actor, this.activity, inboxes);
logger.info(`Deliver queues dispatched: inboxes=${inboxes.size} actorId=${this.actor?.id} activityId=${this.activity?.id}`); this.logger.info(`Deliver queues dispatched: inboxes=${inboxes.size} actorId=${this.actor.id} activityId=${this.activity?.id}`);
} }
} }
@Injectable() @Injectable()
export class ApDeliverManagerService { export class ApDeliverManagerService {
private logger: Logger;
constructor( constructor(
@Inject(DI.followingsRepository) @Inject(DI.followingsRepository)
private followingsRepository: FollowingsRepository, private followingsRepository: FollowingsRepository,
@ -177,7 +179,9 @@ export class ApDeliverManagerService {
private userKeypairService: UserKeypairService, private userKeypairService: UserKeypairService,
private queueService: QueueService, private queueService: QueueService,
private accountUpdateService: AccountUpdateService, private accountUpdateService: AccountUpdateService,
private apLoggerService: ApLoggerService,
) { ) {
this.logger = this.apLoggerService.logger.createSubLogger('deliver-manager');
} }
/** /**
@ -193,6 +197,7 @@ export class ApDeliverManagerService {
this.followingsRepository, this.followingsRepository,
this.queueService, this.queueService,
this.accountUpdateService, this.accountUpdateService,
this.logger,
actor, actor,
activity, activity,
); );
@ -213,6 +218,7 @@ export class ApDeliverManagerService {
this.followingsRepository, this.followingsRepository,
this.queueService, this.queueService,
this.accountUpdateService, this.accountUpdateService,
this.logger,
actor, actor,
activity, activity,
); );
@ -227,6 +233,7 @@ export class ApDeliverManagerService {
this.followingsRepository, this.followingsRepository,
this.queueService, this.queueService,
this.accountUpdateService, this.accountUpdateService,
this.logger,
actor, actor,
activity, activity,
); );