diff --git a/playlet-lib/src/components/Logger/Logger.bs b/playlet-lib/src/components/Logger/Logger.bs index aa3b105a..f35dea0c 100644 --- a/playlet-lib/src/components/Logger/Logger.bs +++ b/playlet-lib/src/components/Logger/Logger.bs @@ -118,11 +118,11 @@ function OnLineSysLog(event as object, dateTime as object, logsFile as string, b ' They're usually repetitive, one is reported for each stream in a DASH ' when a video is blocked if m.sysLogEventDropCounter = 0 - m.global.telemetry.LogEvent = { + LogTelemetryEvent({ level: "error" message: line fingerprint: ["SysLog", info.Status, info.LogType, info.HttpCode, info.Method] - } + }) end if m.sysLogEventDropCounter = (m.sysLogEventDropCounter + 1) mod 10 end function diff --git a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs index 379d98c8..670db5fd 100644 --- a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs +++ b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs @@ -112,7 +112,7 @@ namespace InnertubeService return GetVideoMetadata(videoId, options) end if if code = "MISSING_FORMAT_FIELD" - m.global.telemetry.LogEvent = { + LogTelemetryEvent({ level: "error" message: code fingerprint: code @@ -125,7 +125,7 @@ namespace InnertubeService content_type: "application/json" data: playerResponse.Text() }] - } + }) end if throw exception end try diff --git a/playlet-lib/src/components/Services/Innertube/NodesParser.bs b/playlet-lib/src/components/Services/Innertube/NodesParser.bs index 2762e8d4..5775e03d 100644 --- a/playlet-lib/src/components/Services/Innertube/NodesParser.bs +++ b/playlet-lib/src/components/Services/Innertube/NodesParser.bs @@ -1745,8 +1745,7 @@ namespace Innertube nodeDataString = FormatJson(nodeData) LogWarnNoTelemetry(message + `\n` + nodeDataString) - - m.global.telemetry.LogEvent = { + LogTelemetryEvent ({ level: "warning" message: message fingerprint: message @@ -1759,6 +1758,6 @@ namespace Innertube content_type: "text/plain" data: context.response.request.ToCurlCommand() }] - } + }) end function end namespace diff --git a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs index 427b01fc..f168b99c 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs @@ -571,12 +571,12 @@ function ReportVideoError(errorData as object, url as string) as void end if end if - m.global.telemetry.LogEvent = { + LogTelemetryEvent({ level: "error" message: errorData.title + " " + errorData.body + `\n url: ${url}` fingerprint: errorData.fingerprint attachments: attachments - } + }) end function function OnVideoFinished() as void diff --git a/playlet-lib/src/components/Web/WebServer/Http/HttpRequest.bs b/playlet-lib/src/components/Web/WebServer/Http/HttpRequest.bs index 6877ed04..45a4fea2 100644 --- a/playlet-lib/src/components/Web/WebServer/Http/HttpRequest.bs +++ b/playlet-lib/src/components/Web/WebServer/Http/HttpRequest.bs @@ -100,11 +100,11 @@ namespace Http if operation = invalid or operation = "" LogErrorNoTelemetry("empty request") - m.global.telemetry.LogEvent = { + LogTelemetryEvent({ level: "error" message: "empty request: " + FormatJson({ "m.buffer": m.buffer, "m.buffer_index": m.buffer_index }) fingerprint: ["HttpRequest: empty request"] - } + }) m.ready_for_response = true return false end if diff --git a/playlet-lib/src/source/utils/Logging.bs b/playlet-lib/src/source/utils/Logging.bs index 9e839684..937e9e6c 100644 --- a/playlet-lib/src/source/utils/Logging.bs +++ b/playlet-lib/src/source/utils/Logging.bs @@ -29,6 +29,10 @@ function LogDebug(_arg1 = invalid as dynamic, _arg2 = invalid as dynamic, _arg3 throw "FATAL: Calling LogDebug() which is a stub function" end function +function LogTelemetryEvent(event as object) + m.global.telemetry.LogEvent = event +end function + function ToString(value as dynamic) as string if getInterface(value, "ifString") <> invalid return value