Skip to content

Commit 9391ec7

Browse files
committed
feat: add logging
1 parent 6251c29 commit 9391ec7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/WebRTCIssueDetector.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,32 @@ class WebRTCIssueDetector {
7878
this.wrapRTCPeerConnection();
7979

8080
this.statsReporter.on(PeriodicWebRTCStatsReporter.STATS_REPORT_READY_EVENT, (report: StatsReportItem) => {
81+
const detectStartedAt = Date.now();
82+
8183
this.detectIssues({
8284
data: report.stats,
8385
ignoreSSRCList: params.ignoreSSRCList,
8486
});
8587

88+
const detectFinishedAt = Date.now();
89+
8690
this.calculateNetworkScores(report.stats);
91+
92+
this.logger.debug('Reporter report item processing finished', {
93+
detectIssuesTimeMs: detectFinishedAt - detectStartedAt,
94+
networkScoreCalcTimeMs: Date.now() - detectFinishedAt,
95+
});
8796
});
8897

8998
this.statsReporter.on(PeriodicWebRTCStatsReporter.STATS_REPORTS_PARSED, (data: { timeTaken: number }) => {
90-
this.eventEmitter.emit(EventType.StatsParsingFinished, {
99+
const payload = {
91100
timeTaken: data.timeTaken,
92101
ts: Date.now(),
93-
});
102+
};
103+
104+
this.logger.debug('WID reports parsed', payload);
105+
106+
this.eventEmitter.emit(EventType.StatsParsingFinished, payload);
94107
});
95108
}
96109

@@ -99,6 +112,8 @@ class WebRTCIssueDetector {
99112
throw new Error('WebRTCIssueDetector is already started');
100113
}
101114

115+
this.logger.info('Start watching peer connections');
116+
102117
this.#running = true;
103118
this.statsReporter.startReporting();
104119
}
@@ -108,6 +123,8 @@ class WebRTCIssueDetector {
108123
throw new Error('WebRTCIssueDetector is already stopped');
109124
}
110125

126+
this.logger.info('Stop watching peer connections');
127+
111128
this.#running = false;
112129
this.statsReporter.stopReporting();
113130
}

0 commit comments

Comments
 (0)