Skip to content

Commit

Permalink
feat: イベントリレー時のログの拡充
Browse files Browse the repository at this point in the history
  • Loading branch information
l3tnun committed May 28, 2024
1 parent 7c001fc commit c8b42fe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/model/operator/recording/RecorderModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -954,21 +954,28 @@ class RecorderModel implements IRecorderModel {
return;
}

this.log.system.debug(
`check event relay program. reserveId: ${this.reserve.id}, programId: ${this.reserve.programId}`,
);
const mirakurun = this.mirakurunClientModel.getClient();

// program 情報の取得
let parentProgram: mapid.Program;
try {
parentProgram = await mirakurun.getProgram(this.reserve.programId);
this.log.system.debug(parentProgram);
} catch (err: any) {
this.log.system.error(
`failed to get event relay info. reserveId: ${this.reserve.id} programId: ${this.reserve.programId}`,
`failed to get event relay info. reserveId: ${this.reserve.id}, programId: ${this.reserve.programId}`,
);
return;
}

// event relay の設定の有無を調べる
if (typeof parentProgram.relatedItems === 'undefined') {
this.log.system.debug(
`event relay porgram does not exist. reserveId: ${this.reserve.id}, programId: ${this.reserve.programId}`,
);
return;
}

Expand Down
10 changes: 6 additions & 4 deletions src/model/operator/reservation/ReservationManageModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ class ReservationManageModel implements IReservationManageModel {
* null: すでに予約済み
*/
public async addEventRelay(programId: apid.ProgramId, parentReserve: Reserve): Promise<apid.ReserveId | null> {
this.log.system.info(`add event relay. ${programId}`);
this.log.system.info(`add event relay. reserveId: ${parentReserve.id}, programId: ${programId}`);

// すでに録画されていないか検索する
const reservedPrograms = await this.reserveDB.findProgramId(programId);
if (reservedPrograms.length > 0) {
this.log.system.warn(`already reserved program. ${programId}`);
this.log.system.warn(`already reserved program. reserveId: ${parentReserve.id}, programId: ${programId}`);
return null;
}

Expand All @@ -196,7 +196,7 @@ class ReservationManageModel implements IReservationManageModel {

// 追加
const insertedId = await this.reserveDB.insertOnce(newReserve).catch(err => {
this.log.system.info(`add reservation error: ${programId}`);
this.log.system.info(`add reservation error: reserveId: ${parentReserve.id}, programId: ${programId}`);
this.log.system.error(err);
finalize();
throw new Error('ReservationManageModelAddReserveError');
Expand All @@ -206,7 +206,9 @@ class ReservationManageModel implements IReservationManageModel {
// 完了したのでロック解除
finalize();

this.log.system.info(`successful add event relay. ${programId}`);
this.log.system.info(
`successful add event relay. reserveId: ${parentReserve.id}, newReserveId: ${newReserve.id} programId: ${programId}`,
);

// イベント発行
this.reserveEvent.emitUpdated({
Expand Down

0 comments on commit c8b42fe

Please sign in to comment.