@akc42/app-utils 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/debug.js +8 -12
- package/package.json +1 -1
package/debug.js
CHANGED
|
@@ -19,13 +19,11 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
/*
|
|
22
|
-
The purpose of this module is to provide a debugable capability which can be
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
the
|
|
27
|
-
topic of this debug message and gap is the number of milliseconds since the
|
|
28
|
-
last debug message with the same topic.
|
|
22
|
+
The purpose of this module is to provide a debugable capability which can be dynamically switched on and off browser
|
|
23
|
+
by setting sessionStorage value 'debug' to the config returned by the server. It will post request to '/api/debuglog'
|
|
24
|
+
url with application/json body part containing message, topic and gap, where message is the concatenation of the debug
|
|
25
|
+
parameters separated by space, topic is the topic of this debug message and gap is the number of milliseconds since
|
|
26
|
+
the last debug message with the same topic.
|
|
29
27
|
|
|
30
28
|
Topic data is held in a map, so this module can be used in multiple modules in
|
|
31
29
|
the client and if its the same topic then the gap will be since the last call
|
|
@@ -41,13 +39,11 @@
|
|
|
41
39
|
|
|
42
40
|
debug(..messages) //messages will be concatenated by space
|
|
43
41
|
|
|
44
|
-
the debug function will only log the message on the server if
|
|
45
|
-
config-promise) is set to a string which is a colon separated list of topics
|
|
42
|
+
the debug function will only log the message on the server if sessionStorage "debug" is set to a string which is a colon separated list of topics
|
|
46
43
|
and that list has the topic for this debug call in it.
|
|
47
44
|
|
|
48
45
|
NOTE: It is normally expected for the server to provide a mechanism to update
|
|
49
|
-
the
|
|
50
|
-
specifically overwrite sessionStorage 'debug' item with a new list of topics when you want
|
|
46
|
+
the confgi before it is returned, The main app then overwrites sessionStorage 'debug' item with a new list of topics when you want
|
|
51
47
|
debug to switch on and off dynamically.
|
|
52
48
|
|
|
53
49
|
regardless of whether the message is logged on the server, it is also added to the performance.mark buffer
|
|
@@ -137,7 +133,7 @@ function Debug(t) {
|
|
|
137
133
|
}, '');
|
|
138
134
|
if (initialised) performance.mark(this.topic, { detail: message }); //save our message locally regardless of if enabled
|
|
139
135
|
let enabled = false;
|
|
140
|
-
const debugConf = sessionStorage.
|
|
136
|
+
const debugConf = sessionStorage.get('debug');
|
|
141
137
|
if (debugConf) {
|
|
142
138
|
const topics = debugConf.split(':');
|
|
143
139
|
if (topics.includes(this.topic)) enabled = true;
|