From 90b4b257936975fe50d5b63be46d99d13804e4fc Mon Sep 17 00:00:00 2001 From: mbaas2 Date: Fri, 5 Apr 2024 11:03:26 +0200 Subject: [PATCH 1/7] LOGMODE 'w' (intentionally lowercase) records W*-activities into file --- JSWC/Log.aplf | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/JSWC/Log.aplf b/JSWC/Log.aplf index e37c548..fde8272 100644 --- a/JSWC/Log.aplf +++ b/JSWC/Log.aplf @@ -1,4 +1,4 @@ -mode Log msg + mode Log msg;json ⍝ Log modes: Controlled by JSWC.LOGMODES ⍝ D: Debug ⍝ E: Error @@ -8,6 +8,18 @@ mode Log msg ⍝ R: Receive on WebSocket ⍝ C: Connect or Disconnect ⍝ U: Unsupported feature +⍝ w: log eW* object/property access (for testing) -→(mode∊LOGMODES)↓0 -⎕←((,'ZI2,<:>,ZI2,<.>,ZI3' ⎕FMT 1 3⍴¯3↑⎕TS),' ',mode,':') msg + →(mode∊LOGMODES)↓0 + ⎕←((,'ZI2,<:>,ZI2,<.>,ZI3'⎕FMT 1 3⍴¯3↑⎕TS),' ',mode,':')msg + :If mode≡'w' + ⍝ primitive: we collect json objects in that file - it's not "json" though...(needs to be enclosed in []) + ⍝ also we do not care about max file size, we just keep appending + ⍝ do it's the responsibility of the user to clean up the file. + ⍝ That's why mode='w' is useful - it's not part of the default (⎕A) + ⍝ and needs to be set explicitely! + ⍝ (see eWC Tests for example usage that deletes the file before running tests + ⍝ and also adds the "[]" ) + msg←('(:.*,)(.*)$'⎕R('\1 TS: [',(∊(⍕¨¯4↑⎕TS),¨','),'],\2')⍠'Greedy' 0)msg + (⊂msg)⎕NPUT(JSWCFolder,'objectlog.json5')2 + :EndIf From 1d9a51efc368a78cc395310ebd95c192c80e10af Mon Sep 17 00:00:00 2001 From: mbaas2 Date: Fri, 5 Apr 2024 11:04:01 +0200 Subject: [PATCH 2/7] =?UTF-8?q?add=20'w'logging=20to=20=E2=88=86WC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JSWC/dWC.aplf | 1 + 1 file changed, 1 insertion(+) diff --git a/JSWC/dWC.aplf b/JSWC/dWC.aplf index 67d4580..164ea72 100644 --- a/JSWC/dWC.aplf +++ b/JSWC/dWC.aplf @@ -117,6 +117,7 @@ :EndIf 'D' Log '*** CREATE ',WC.WC.Properties.Type,' ',WC.WC.ID,' at ',⍕3↑showCallStack + 'w' Log '{Caller: "',(2⊃⎕si),'", Action:"WC", ID:"',WC.WC.ID,'", Type:"',WC.WC.Properties.Type,'", Properties:[',(¯1↓∊{'"',⍵,'",'}¨propnames),']},' fixSendEvents WC.WC.(ID Properties) sendObject WC WC.WC.ID From 2ad2615b536320ce25df1146b1330d91863d95a0 Mon Sep 17 00:00:00 2001 From: mbaas2 Date: Fri, 5 Apr 2024 11:04:39 +0200 Subject: [PATCH 3/7] =?UTF-8?q?add=20'w'-logging=20to=20=E2=88=86WG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JSWC/dWG.aplf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/JSWC/dWG.aplf b/JSWC/dWG.aplf index 753ab2f..7a007d1 100644 --- a/JSWC/dWG.aplf +++ b/JSWC/dWG.aplf @@ -92,3 +92,5 @@ :If 1=≡Props R←⊃R :EndIf + + 'w' Log '{Caller: "',(2⊃⎕si),'", Action:"WG", ID:"', Name,'",Properties:[',(¯1↓∊{'"',⍵,'",'}¨p),']},' From 3a66588e5587bde2310ed066ef4e1d5b42f19a44 Mon Sep 17 00:00:00 2001 From: mbaas2 Date: Fri, 5 Apr 2024 11:05:00 +0200 Subject: [PATCH 4/7] =?UTF-8?q?add=20'w'-logging=20to=20=E2=88=86WS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JSWC/dWS.aplf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/JSWC/dWS.aplf b/JSWC/dWS.aplf index b62b9bd..c63aa52 100644 --- a/JSWC/dWS.aplf +++ b/JSWC/dWS.aplf @@ -89,3 +89,5 @@ :If ~0=⍴WS.WS.Properties.⎕NL-2 sendObject WS WS.WS.ID :EndIf + + 'w' Log '{Caller: "',(2⊃⎕si),'", Action:"WS", ID:"',WS.WS.ID,'", Properties:[',(¯1↓∊{'"',⍵,'",'}¨names),']},' From 9c1038977b76d71aaa930faf44e3125ab5b954d2 Mon Sep 17 00:00:00 2001 From: mbaas2 Date: Fri, 5 Apr 2024 11:06:04 +0200 Subject: [PATCH 5/7] add option to set LOGMODES through env/cfg var "EWC_LOGMODES" --- JSWC/Init.aplf | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/JSWC/Init.aplf b/JSWC/Init.aplf index 7a51bfc..dea40f7 100644 --- a/JSWC/Init.aplf +++ b/JSWC/Init.aplf @@ -6,7 +6,7 @@ :Case 1 ⋄ mode←⊃args ⋄ CODELOCATION←⊃⎕RSI :Case 2 ⋄ (mode CODELOCATION)←args :Else - 'Right agument: mode [codelocation]'⎕SIGNAL 5 + 'Right argument: mode [codelocation]'⎕SIGNAL 5 :EndSelect :If 0=⎕NC'prefix' @@ -49,7 +49,9 @@ MAXLOG←2000 :EndIf :If 0=⎕NC'LOGMODES' - LOGMODES←⎕A ⍝ Log everything (see Log) + :If 0=≢LOGMODES←1⊃160⌶'EWC_LOGMODES' ⍝ do we have a default in the environment? + LOGMODES←⎕A ⍝ Log everything (see Log) + :EndIf :EndIf :If 0=⎕NC'RESOURCES' RESOURCES←1 2⍴⊂'' @@ -79,7 +81,7 @@ make_JSWC CODELOCATION ⍝ So create the timer here :EndIf - :If 9=⎕NC 'WSS' + :If 9=⎕NC'WSS' ⎕←'Closing existing Web Socket Server...' WSS.Stop ⎕DL 5 @@ -121,7 +123,7 @@ (⍕z)⎕SIGNAL 11 :EndIf - :If 4≥⍴devCaps←'.' ⎕WG 'DevCaps' + :If 4≥⍴devCaps←'.'⎕WG'DevCaps' DPR←100÷⍨4⊃devCaps :Else DPR←1 From 22e31c260bfb3b9c911fc03d5b6711dc7e24a415 Mon Sep 17 00:00:00 2001 From: mbaas2 Date: Fri, 5 Apr 2024 17:29:14 +0200 Subject: [PATCH 6/7] env/cfg var "EWC_TRACEDEMOS" allows to control if we want to trace through demos --- demo/Run.aplf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demo/Run.aplf b/demo/Run.aplf index 901fefc..533158e 100644 --- a/demo/Run.aplf +++ b/demo/Run.aplf @@ -22,6 +22,10 @@ :EndTrap JSWC.NOIDQ←0 ⍝ Allow interactive DQ + ⍝ trace into demo functions? + :If 1≡⊃2⊃⎕VFI 2 ⎕NQ'.' 'GetEnvironment' 'EWC_TRACEDEMOS' + #.demo.({'Demo'≡4↑⍵:1 ⎕STOP ⍵}¨(⎕NL-3)~'DemoMenu' 'DemoDefault') + :EndIf :Select JSWC.MODE :Case 0 ⍝ Desktop From e5adab82e1216576ead6d6178478bca7641eed20 Mon Sep 17 00:00:00 2001 From: mbaas2 Date: Fri, 5 Apr 2024 17:30:40 +0200 Subject: [PATCH 7/7] new settings to control tracing in demos or testing --- Tests/eWC_createBrowser.aplf | 2 +- Tests/eWC_defaults.json5 | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/eWC_createBrowser.aplf b/Tests/eWC_createBrowser.aplf index 14e52da..1c1f2e5 100644 --- a/Tests/eWC_createBrowser.aplf +++ b/Tests/eWC_createBrowser.aplf @@ -1,6 +1,6 @@ {larg}eWC_createBrowser rarg;cmd ⍝ ⍵ corresponds to Run's ⍵ - cmd←'LOAD=',EWC_HOME,' LX="demo.Run ',(⍕rarg),'" EWC_PORT=22344' + cmd←'LOAD=',EWC_HOME,' LX="demo.Run ',(⍕rarg),'" EWC_PORT=22344 EWC_LOGMODES=w',(1=0 _Env'TRACE_DEMOS')/' EWC_TRACEDEMOS=1' p←⎕NEW #.APLProcess(''cmd 0 '' ''EWC_HOME) ⍝ do not localise this! #.S.InitBrowser larg diff --git a/Tests/eWC_defaults.json5 b/Tests/eWC_defaults.json5 index 60c1168..ea257b5 100644 --- a/Tests/eWC_defaults.json5 +++ b/Tests/eWC_defaults.json5 @@ -2,4 +2,6 @@ SCREENSHOT: 2, // 0: never, 1: on error, 2: always RANDOMORDER: 1, // execute tests in random order? PROGRESSINDICATOR: 1, // no info, 1: show name of next test, 2: and wait for keypress + TRACE_DEMOS: 0, // trace into the demos? + TRACE_TESTS: 1, // trace into the tests? } \ No newline at end of file