Skip to content

Commit

Permalink
fix internal message logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vpalmisano committed Apr 3, 2024
1 parent 0dccc16 commit eec198b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/peer-connection-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ window.collectPeerConnectionStats = async (raw = false, verbose = false) => {
stats.push(ret)
}
} catch (err) {
console.error(`getPeerConnectionStats error: ${err.message}`, err)
log(`getPeerConnectionStats error: ${err.message}`, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/peer-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ window.RTCPeerConnection = function (conf, options) {
PeerConnections.set(id, pc)

pc.addEventListener('connectionstatechange', () => {
log(`RTCPeerConnection-${id} changed to: ${pc.connectionState}`)
if (pc.connectionState === 'closed') {
log(`RTCPeerConnection closed (connectionState: ${pc.connectionState})`)
PeerConnections.delete(id)
}
})
Expand Down
5 changes: 3 additions & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,16 +1441,17 @@ window.SERVER_USE_HTTPS = ${this.serverUseHttps};
: null
if (!filter || text.match(filter)) {
const errorOrWarning = ['error', 'warning'].includes(type)
const isWebrtcPerf = text.includes('[webrtcperf]')
if (saveFile) {
if (!errorOrWarning && text.length > 1024) {
if (!errorOrWarning && !isWebrtcPerf && text.length > 1024) {
text = text.slice(0, 1024) + `... +${text.length - 1024} bytes`
}
await saveFile.write(
`${new Date().toISOString()} [page ${index + 1}] (${type}) ${text}\n`,
)
}
if (this.showPageLog) {
if (!errorOrWarning && text.length > 256) {
if (!errorOrWarning && !isWebrtcPerf && text.length > 256) {
text = text.slice(0, 256) + `... +${text.length - 256} bytes`
}
console.log(
Expand Down

0 comments on commit eec198b

Please sign in to comment.