From c0e2330df93fe9b699de468a68edea95d4b8a49d Mon Sep 17 00:00:00 2001 From: Sushmitha Mallesh Date: Mon, 20 Sep 2021 16:16:46 +0530 Subject: [PATCH 1/2] Write to system log API removed --- source/core/library_coreHelpers.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/core/library_coreHelpers.js b/source/core/library_coreHelpers.js index 9e061d8be..d553341ff 100644 --- a/source/core/library_coreHelpers.js +++ b/source/core/library_coreHelpers.js @@ -6,9 +6,6 @@ var coreHelpersCAPI = { jsExecutionContextFPSync: function () { Module.coreHelpers.jsExecutionContextFPSync.apply(undefined, arguments); - }, - jsSystemLogging_WriteMessageUTF8: function () { - Module.coreHelpers.jsSystemLogging_WriteMessageUTF8.apply(undefined, arguments); } }; From fc89f65929a05006108971f4d9953f2611238090 Mon Sep 17 00:00:00 2001 From: Sushmitha Mallesh Date: Mon, 20 Sep 2021 16:18:12 +0530 Subject: [PATCH 2/2] Write to system log API removed --- source/core/module_coreHelpers.js | 23 ---- source/io/FileIO.cpp | 37 ------ .../fixtures/systemlogging/SystemLogging.via | 21 ---- .../karma/systemlogging/SystemLogging.Test.js | 118 ------------------ 4 files changed, 199 deletions(-) delete mode 100644 test-it/karma/fixtures/systemlogging/SystemLogging.via delete mode 100644 test-it/karma/systemlogging/SystemLogging.Test.js diff --git a/source/core/module_coreHelpers.js b/source/core/module_coreHelpers.js index 23368d020..3b4a375db 100644 --- a/source/core/module_coreHelpers.js +++ b/source/core/module_coreHelpers.js @@ -26,29 +26,6 @@ var assignCoreHelpers; fpSync(fpString); }; - Module.coreHelpers.jsSystemLogging_WriteMessageUTF8 = function ( - messageTypeRef, messageDataRef, - severityTypeRef, severityDataRef) { - var messageValueRef = Module.eggShell.createValueRef(messageTypeRef, messageDataRef); - var severityValueRef = Module.eggShell.createValueRef(severityTypeRef, severityDataRef); - var message = Module.eggShell.readString(messageValueRef); - var severity = Module.eggShell.readDouble(severityValueRef); - switch (severity) { - case 0: - console.error(message); - break; - case 1: - console.warn(message); - break; - case 2: - console.info(message); - break; - default: - console.log(message); - break; - } - }; - publicAPI.coreHelpers.setFPSyncFunction = function (fn) { if (typeof fn !== 'function') { throw new Error('FPSync must be a callable function'); diff --git a/source/io/FileIO.cpp b/source/io/FileIO.cpp index d35d5e5f2..4041b9151 100644 --- a/source/io/FileIO.cpp +++ b/source/io/FileIO.cpp @@ -39,14 +39,6 @@ namespace Vireo { -#if kVireoOS_emscripten -extern "C" { - extern void jsSystemLogging_WriteMessageUTF8( - TypeRef messageType, StringRef * message, - TypeRef severityType, Int32 * severity); -} -#endif - typedef Int32 FileHandle; #ifdef VIREO_FILESYSTEM @@ -385,31 +377,6 @@ VIREO_FUNCTION_SIGNATURE2(Println, StaticType, void) } #endif //------------------------------------------------------------ -#if kVireoOS_emscripten -struct SystemLogging_WriteMessageUTF8ParamBlock : InstructionCore -{ - _ParamDef(StringRef, Ignored0In); - _ParamDef(StringRef, Ignored1In); - _ParamDef(StringRef, MessageIn); - _ParamDef(Int32, SeverityIn); - _ParamDef(ErrorCluster, ErrorInOut); - NEXT_INSTRUCTION_METHOD() -}; - -// An instruction to enable the Write to System Log VI which uses an SLI call to SystemLogging_WriteMessageUTF8 -VIREO_FUNCTION_SIGNATURET(SystemLogging_WriteMessageUTF8, SystemLogging_WriteMessageUTF8ParamBlock) -{ - TypeRef typeRefInt32 = TypeManagerScope::Current()->FindType("Int32"); - - if (!_Param(ErrorInOut).status) { - jsSystemLogging_WriteMessageUTF8( - _Param(MessageIn)->Type(), _ParamPointer(MessageIn), - typeRefInt32, _ParamPointer(SeverityIn)); - } - return _NextInstruction(); -} -#endif -//------------------------------------------------------------ DEFINE_VIREO_BEGIN(FileSystem) // Types DEFINE_VIREO_TYPE(FileHandle, "Int32") @@ -423,10 +390,6 @@ DEFINE_VIREO_BEGIN(FileSystem) DEFINE_VIREO_FUNCTION(Printf, "p(i(VarArgCount)i(String)i(StaticTypeAndData))") #endif //-------- -#if kVireoOS_emscripten - DEFINE_VIREO_FUNCTION(SystemLogging_WriteMessageUTF8, "p(i(.String) i(.String) i(.String) i(.Int32) io(ErrorCluster))") -#endif - //-------- #ifdef VIREO_FILESYSTEM DEFINE_VIREO_FUNCTION(FileOpen, "p(i(String)i(Int32)i(Int32)o(FileHandle))") DEFINE_VIREO_FUNCTION(FileSize, "p(i(FileHandle)o(Int32))") diff --git a/test-it/karma/fixtures/systemlogging/SystemLogging.via b/test-it/karma/fixtures/systemlogging/SystemLogging.via deleted file mode 100644 index 15be5e350..000000000 --- a/test-it/karma/fixtures/systemlogging/SystemLogging.via +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2020 National Instruments -// SPDX-License-Identifier: MIT - -define(MyVI dv(VirtualInstrument ( - Locals: c( - e(c( - e(.Boolean status) - e(.Int32 code) - e(.String source) - ) error) - e(.String ignored1) - e(.String ignored2) - e(.String message) - e(.Int32 severity) - ) - clump ( - SystemLogging_WriteMessageUTF8(ignored1 ignored2 message severity error) - ) -) ) ) - -enqueue(MyVI) diff --git a/test-it/karma/systemlogging/SystemLogging.Test.js b/test-it/karma/systemlogging/SystemLogging.Test.js deleted file mode 100644 index db6600621..000000000 --- a/test-it/karma/systemlogging/SystemLogging.Test.js +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2020 National Instruments -// SPDX-License-Identifier: MIT - -describe('Performing a system log', function () { - 'use strict'; - // Reference aliases - const vireoHelpers = window.vireoHelpers; - const vireoRunner = window.testHelpers.vireoRunner; - const fixtures = window.testHelpers.fixtures; - let vireo; - - const systemLoggingViaUrl = fixtures.convertToAbsoluteFromFixturesDir('systemlogging/SystemLogging.via'); - - beforeAll(function (done) { - fixtures.preloadAbsoluteUrls([ - systemLoggingViaUrl - ], done); - }); - - beforeAll(async function () { - vireo = await vireoHelpers.createInstance(); - }); - - afterAll(function () { - vireo = undefined; - }); - - beforeEach(async function () { - spyOn(console, 'error'); - spyOn(console, 'warn'); - spyOn(console, 'info'); - spyOn(console, 'log'); - }); - - it('with error severity calls console error', async function () { - const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); - const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); - const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); - - viPathWriter('message', 'this should be an error'); - viPathWriter('severity', 0); - const {rawPrint, rawPrintError} = await runSlicesAsync(); - - expect(console.error).toHaveBeenCalledTimes(1); - expect(console.error).toHaveBeenCalledWith('this should be an error'); - expect(console.warn).not.toHaveBeenCalled(); - expect(console.info).not.toHaveBeenCalled(); - expect(console.log).not.toHaveBeenCalled(); - expect(rawPrint).toBeEmptyString(); - expect(rawPrintError).toBeEmptyString(); - expect(viPathParser('error.status')).toBeFalse(); - expect(viPathParser('error.code')).toBe(0); - expect(viPathParser('error.source')).toBeEmptyString(); - }); - - it('with warn severity calls console warn', async function () { - const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); - const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); - const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); - - viPathWriter('message', 'this should be a warning'); - viPathWriter('severity', 1); - const {rawPrint, rawPrintError} = await runSlicesAsync(); - - expect(console.error).not.toHaveBeenCalled(); - expect(console.warn).toHaveBeenCalledTimes(1); - expect(console.warn).toHaveBeenCalledWith('this should be a warning'); - expect(console.info).not.toHaveBeenCalled(); - expect(console.log).not.toHaveBeenCalled(); - expect(rawPrint).toBeEmptyString(); - expect(rawPrintError).toBeEmptyString(); - expect(viPathParser('error.status')).toBeFalse(); - expect(viPathParser('error.code')).toBe(0); - expect(viPathParser('error.source')).toBeEmptyString(); - }); - - it('with info severity calls console info', async function () { - const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); - const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); - const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); - - viPathWriter('message', 'this should be an info'); - viPathWriter('severity', 2); - const {rawPrint, rawPrintError} = await runSlicesAsync(); - - expect(console.error).not.toHaveBeenCalled(); - expect(console.warn).not.toHaveBeenCalled(); - expect(console.info).toHaveBeenCalledTimes(1); - expect(console.info).toHaveBeenCalledWith('this should be an info'); - expect(console.log).not.toHaveBeenCalled(); - expect(rawPrint).toBeEmptyString(); - expect(rawPrintError).toBeEmptyString(); - expect(viPathParser('error.status')).toBeFalse(); - expect(viPathParser('error.code')).toBe(0); - expect(viPathParser('error.source')).toBeEmptyString(); - }); - - it('with invalid severity calls console log', async function () { - const runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, systemLoggingViaUrl); - const viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); - const viPathWriter = vireoRunner.createVIPathWriter(vireo, 'MyVI'); - - viPathWriter('message', 'this should be a log'); - viPathWriter('severity', 70); - const {rawPrint, rawPrintError} = await runSlicesAsync(); - - expect(console.error).not.toHaveBeenCalled(); - expect(console.warn).not.toHaveBeenCalled(); - expect(console.info).not.toHaveBeenCalled(); - expect(console.log).toHaveBeenCalledTimes(1); - expect(console.log).toHaveBeenCalledWith('this should be a log'); - expect(rawPrint).toBeEmptyString(); - expect(rawPrintError).toBeEmptyString(); - expect(viPathParser('error.status')).toBeFalse(); - expect(viPathParser('error.code')).toBe(0); - expect(viPathParser('error.source')).toBeEmptyString(); - }); -});