Skip to content

Commit 1eff236

Browse files
author
Mint de Wit
authored
Merge pull request Sofie-Automation#1140 from tv2norge-collab/contribute/EAV-158-release51
refactor(live-status-gw): reassign log levels
2 parents 0f73bed + 0c25dbb commit 1eff236

22 files changed

+119
-87
lines changed

packages/live-status-gateway/src/collections/adLibActionsHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class AdLibActionsHandler
2222
}
2323

2424
async changed(id: AdLibActionId, changeType: string): Promise<void> {
25-
this._logger.info(`${this._name} ${changeType} ${id}`)
25+
this.logDocumentChange(id, changeType)
2626
if (!this._collectionName) return
2727
const col = this._core.getCollection(this._collectionName)
2828
if (!col) throw new Error(`collection '${this._collectionName}' not found!`)
@@ -31,7 +31,7 @@ export class AdLibActionsHandler
3131
}
3232

3333
async update(source: string, data: SelectedPartInstances | undefined): Promise<void> {
34-
this._logger.info(`${this._name} received partInstances update from ${source}`)
34+
this.logUpdateReceived('partInstances', source)
3535
const prevRundownId = this._curRundownId
3636
this._curPartInstance = data ? data.current ?? data.next : undefined
3737
this._curRundownId = this._curPartInstance ? this._curPartInstance.rundownId : undefined
@@ -69,7 +69,7 @@ export class AdLibActionsHandler
6969

7070
// override notify to implement empty array handling
7171
async notify(data: AdLibAction[] | undefined): Promise<void> {
72-
this._logger.info(`${this._name} notifying update with ${data?.length} adLibActions`)
72+
this.logNotifyingUpdate(data?.length)
7373
if (data !== undefined) {
7474
for (const observer of this._observers) {
7575
await observer.update(this._name, data)

packages/live-status-gateway/src/collections/adLibsHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class AdLibsHandler
2323
}
2424

2525
async changed(id: PieceId, changeType: string): Promise<void> {
26-
this._logger.info(`${this._name} ${changeType} ${id}`)
26+
this.logDocumentChange(id, changeType)
2727
if (!this._collectionName) return
2828
const col = this._core.getCollection(this._collectionName)
2929
if (!col) throw new Error(`collection '${this._collectionName}' not found!`)
@@ -32,7 +32,7 @@ export class AdLibsHandler
3232
}
3333

3434
async update(source: string, data: SelectedPartInstances | undefined): Promise<void> {
35-
this._logger.info(`${this._name} received adLibs update from ${source}`)
35+
this.logUpdateReceived('partInstances', source)
3636
const prevRundownId = this._currentRundownId
3737
this._currentPartInstance = data ? data.current ?? data.next : undefined
3838
this._currentRundownId = this._currentPartInstance?.rundownId
@@ -70,7 +70,7 @@ export class AdLibsHandler
7070

7171
// override notify to implement empty array handling
7272
async notify(data: AdLibPiece[] | undefined): Promise<void> {
73-
this._logger.info(`${this._name} notifying update with ${data?.length} adLibs`)
73+
this.logNotifyingUpdate(data?.length)
7474
if (data !== undefined) {
7575
for (const observer of this._observers) {
7676
await observer.update(this._name, data)

packages/live-status-gateway/src/collections/globalAdLibActionsHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class GlobalAdLibActionsHandler
3030
}
3131

3232
async changed(id: RundownBaselineAdLibActionId, changeType: string): Promise<void> {
33-
this._logger.info(`${this._name} ${changeType} ${id}`)
33+
this.logDocumentChange(id, changeType)
3434
if (!this._collectionName) return
3535
const col = this._core.getCollection(this._collectionName)
3636
if (!col) throw new Error(`collection '${this._collectionName}' not found!`)
@@ -39,7 +39,7 @@ export class GlobalAdLibActionsHandler
3939
}
4040

4141
async update(source: string, data: SelectedPartInstances | undefined): Promise<void> {
42-
this._logger.info(`${this._name} received partInstances update from ${source}`)
42+
this.logUpdateReceived('partInstances', source)
4343
const prevRundownId = this._currentRundownId
4444
const partInstance = data ? data.current ?? data.next : undefined
4545
this._currentRundownId = partInstance?.rundownId
@@ -75,7 +75,7 @@ export class GlobalAdLibActionsHandler
7575

7676
// override notify to implement empty array handling
7777
async notify(data: RundownBaselineAdLibAction[] | undefined): Promise<void> {
78-
this._logger.info(`${this._name} notifying update with ${data?.length} globalAdLibActions`)
78+
this.logNotifyingUpdate(data?.length)
7979
if (data !== undefined) {
8080
for (const observer of this._observers) {
8181
await observer.update(this._name, data)

packages/live-status-gateway/src/collections/globalAdLibsHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class GlobalAdLibsHandler
3030
}
3131

3232
async changed(id: PieceId, changeType: string): Promise<void> {
33-
this._logger.info(`${this._name} ${changeType} ${id}`)
33+
this.logDocumentChange(id, changeType)
3434
if (!this._collectionName) return
3535
const collection = this._core.getCollection(this._collectionName)
3636
if (!collection) throw new Error(`collection '${this._collectionName}' not found!`)
@@ -39,7 +39,7 @@ export class GlobalAdLibsHandler
3939
}
4040

4141
async update(source: string, data: SelectedPartInstances | undefined): Promise<void> {
42-
this._logger.info(`${this._name} received globalAdLibs update from ${source}`)
42+
this.logUpdateReceived('globalAdLibs', source)
4343
const prevRundownId = this._currentRundownId
4444
const partInstance = data ? data.current ?? data.next : undefined
4545
this._currentRundownId = partInstance?.rundownId
@@ -75,7 +75,7 @@ export class GlobalAdLibsHandler
7575

7676
// override notify to implement empty array handling
7777
async notify(data: RundownBaselineAdLibItem[] | undefined): Promise<void> {
78-
this._logger.info(`${this._name} notifying update with ${data?.length} globalAdLibs`)
78+
this.logNotifyingUpdate(data?.length)
7979
if (data !== undefined) {
8080
for (const observer of this._observers) {
8181
await observer.update(this._name, data)

packages/live-status-gateway/src/collections/partHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class PartHandler
2626
}
2727

2828
async changed(id: PartId, changeType: string): Promise<void> {
29-
this._logger.info(`${this._name} ${changeType} ${id}`)
29+
this.logDocumentChange(id, changeType)
3030
if (!this._collectionName) return
3131
const collection = this._core.getCollection(this._collectionName)
3232
if (!collection) throw new Error(`collection '${this._collectionName}' not found!`)
@@ -46,11 +46,11 @@ export class PartHandler
4646
const partInstances = data as SelectedPartInstances
4747
switch (source) {
4848
case PlaylistHandler.name:
49-
this._logger.info(`${this._name} received playlist update ${rundownPlaylist?._id}`)
49+
this.logUpdateReceived('playlist', source, `rundownPlaylistId ${rundownPlaylist?._id}`)
5050
this._activePlaylist = rundownPlaylist
5151
break
5252
case PartInstancesHandler.name:
53-
this._logger.info(`${this._name} received partInstances update from ${source}`)
53+
this.logUpdateReceived('partInstances', source)
5454
this._currentPartInstance = partInstances.current
5555
break
5656
default:
@@ -89,7 +89,7 @@ export class PartHandler
8989
await this._partsHandler.setParts(allParts)
9090
}
9191
if (prevCurPartInstance !== this._currentPartInstance) {
92-
this._logger.info(
92+
this._logger.debug(
9393
`${this._name} found updated partInstances with current part ${this._activePlaylist?.currentPartInfo?.partInstanceId}`
9494
)
9595
if (!collection) throw new Error(`collection '${this._collectionName}' not found!`)

packages/live-status-gateway/src/collections/partInstancesHandler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class PartInstancesHandler
4444
}
4545

4646
async changed(id: PartInstanceId, changeType: string): Promise<void> {
47-
this._logger.info(`${this._name} ${changeType} ${id}`)
47+
this.logDocumentChange(id, changeType)
4848
if (!this._collectionName || this._subscriptionPending) return
4949

5050
this._throttledUpdateAndNotify()
@@ -101,10 +101,10 @@ export class PartInstancesHandler
101101
const prevRundownIds = this._rundownIds.map((rid) => rid)
102102
const prevActivationId = this._activationId
103103

104-
this._logger.info(
105-
`${this._name} received playlist update ${data?._id}, active ${
106-
data?.activationId ? true : false
107-
} from ${source}`
104+
this.logUpdateReceived(
105+
'playlist',
106+
source,
107+
`rundownPlaylistId ${data?._id}, active ${data?.activationId ? true : false}`
108108
)
109109
this._currentPlaylist = data
110110
if (!this._collectionName) return

packages/live-status-gateway/src/collections/partsHandler.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ export class PartsHandler
2222
}
2323

2424
async setParts(parts: DBPart[]): Promise<void> {
25-
this._logger.info(`'${this._name}' handler received parts update with ${parts.length} parts`)
25+
this.logUpdateReceived('parts', parts.length)
2626
this._collectionData = parts
2727
await this.throttledNotify(this._collectionData)
2828
}
2929

3030
async notify(data: DBPart[] | undefined): Promise<void> {
31-
this._logger.info(
32-
`${this._name} notifying all observers of an update with ${this._collectionData?.length} parts`
33-
)
31+
this.logNotifyingUpdate(this._collectionData?.length)
3432
if (data !== undefined) {
3533
for (const observer of this._observers) {
3634
await observer.update(this._name, data)

packages/live-status-gateway/src/collections/pieceInstancesHandler.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class PieceInstancesHandler
5656
}
5757

5858
async changed(id: PieceInstanceId, changeType: string): Promise<void> {
59-
this._logger.info(`${this._name} ${changeType} ${id}`)
59+
this.logDocumentChange(id, changeType)
6060
if (!this._collectionName || this._subscriptionPending) return
6161
this._throttledUpdateAndNotify()
6262
}
@@ -111,9 +111,7 @@ export class PieceInstancesHandler
111111
const prevPartInstanceIds = this._partInstanceIds
112112
const prevActivationId = this._activationId
113113

114-
this._logger.info(
115-
`${this._name} received playlist update ${data?._id}, active ${!!data?.activationId} from ${source}`
116-
)
114+
this.logUpdateReceived('playlist', source, `rundownPlaylistId ${data?._id}, active ${!!data?.activationId}`)
117115
this._currentPlaylist = data
118116
if (!this._collectionName) return
119117

packages/live-status-gateway/src/collections/playlistHandler.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,25 @@ import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
77
import { RundownPlaylistId } from '@sofie-automation/corelib/dist/dataModel/Ids'
88

99
export class PlaylistsHandler
10-
extends CollectionBase<DBRundownPlaylist[], undefined, undefined>
10+
extends CollectionBase<DBRundownPlaylist[], undefined, CollectionName.RundownPlaylists>
1111
implements Collection<DBRundownPlaylist[]>
1212
{
1313
public observerName: string
1414

1515
constructor(logger: Logger, coreHandler: CoreHandler) {
16-
super(PlaylistsHandler.name, undefined, undefined, logger, coreHandler)
16+
super(PlaylistsHandler.name, CollectionName.RundownPlaylists, undefined, logger, coreHandler)
1717
this.observerName = this._name
1818
}
1919

2020
async setPlaylists(playlists: DBRundownPlaylist[]): Promise<void> {
21-
this._logger.info(`'${this._name}' handler received playlists update with ${playlists.length} playlists`)
21+
this.logUpdateReceived('playlists', playlists.length)
2222
this._collectionData = playlists
2323
await this.notify(this._collectionData)
2424
}
2525

2626
// override notify to implement empty array handling
2727
async notify(data: DBRundownPlaylist[] | undefined): Promise<void> {
28-
this._logger.info(
29-
`${this._name} notifying all observers of an update with ${this._collectionData?.length} playlists`
30-
)
28+
this.logNotifyingUpdate(this._collectionData?.length)
3129
if (data !== undefined) {
3230
for (const observer of this._observers) {
3331
await observer.update(this._name, data)
@@ -78,7 +76,7 @@ export class PlaylistHandler
7876
}
7977

8078
async changed(id: RundownPlaylistId, changeType: string): Promise<void> {
81-
this._logger.info(`${this._name} ${changeType} ${id}`)
79+
this.logDocumentChange(id, changeType)
8280
if (!this._collectionName) return
8381
const collection = this._core.getCollection(this._collectionName)
8482
if (!collection) throw new Error(`collection '${this._collectionName}' not found!`)

packages/live-status-gateway/src/collections/rundownHandler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CoreHandler } from '../coreHandler'
33
import { CollectionBase, Collection, CollectionObserver } from '../wsHandler'
44
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
55
import { DBRundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
6+
import { unprotectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
67
import { PartInstancesHandler, SelectedPartInstances } from './partInstancesHandler'
78
import { RundownId, RundownPlaylistId } from '@sofie-automation/corelib/dist/dataModel/Ids'
89
import { CollectionName } from '@sofie-automation/corelib/dist/dataModel/Collections'
@@ -24,7 +25,7 @@ export class RundownHandler
2425
}
2526

2627
async changed(id: RundownId, changeType: string): Promise<void> {
27-
this._logger.info(`${this._name} ${changeType} ${id}`)
28+
this.logDocumentChange(id, changeType)
2829
if (id !== this._currentRundownId)
2930
throw new Error(`${this._name} received change with unexpected id ${id} !== ${this._currentRundownId}`)
3031
if (!this._collectionName) return
@@ -42,11 +43,11 @@ export class RundownHandler
4243
const partInstances = data as SelectedPartInstances
4344
switch (source) {
4445
case PlaylistHandler.name:
45-
this._logger.info(`${this._name} received playlist update ${rundownPlaylist?._id}`)
46+
this.logUpdateReceived('playlist', source, unprotectString(rundownPlaylist?._id))
4647
this._currentPlaylistId = rundownPlaylist?._id
4748
break
4849
case PartInstancesHandler.name:
49-
this._logger.info(`${this._name} received partInstances update from ${source}`)
50+
this.logUpdateReceived('partInstances', source)
5051
this._currentRundownId = partInstances.current?.rundownId ?? partInstances.next?.rundownId
5152
break
5253
default:

0 commit comments

Comments
 (0)