mentie 0.1.8 → 0.1.9
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/modules/logging.js +11 -5
- package/package.json +1 -1
package/modules/logging.js
CHANGED
|
@@ -15,21 +15,27 @@ const should_log = levels => {
|
|
|
15
15
|
|
|
16
16
|
const add_trace = messages => {
|
|
17
17
|
|
|
18
|
-
//
|
|
19
|
-
if( typeof window === 'undefined' ) return null
|
|
20
|
-
|
|
21
|
-
// Try to add stack to messages
|
|
18
|
+
// Try to add stack to messages if needed
|
|
22
19
|
try {
|
|
23
20
|
|
|
21
|
+
// Do nothing if we are not in a browser
|
|
22
|
+
if( typeof window === 'undefined' ) return messages
|
|
23
|
+
|
|
24
|
+
// If there is no trace=true in the url, do nothing
|
|
25
|
+
if( !window.location?.search?.includes?.( 'trace=true' ) ) return messages
|
|
26
|
+
|
|
27
|
+
|
|
24
28
|
// Get the stack trace
|
|
25
29
|
let { stack } = new Error()
|
|
26
30
|
|
|
27
|
-
// Remove the first line of the stack trace
|
|
31
|
+
// Remove the first line of the stack trace
|
|
28
32
|
stack = stack.split( '\n' ).slice( 1 ).join( '\n' )
|
|
29
33
|
|
|
30
34
|
// Add the trace to the messages
|
|
31
35
|
messages.push( { stack } )
|
|
32
36
|
|
|
37
|
+
return messages
|
|
38
|
+
|
|
33
39
|
} catch ( error ) {
|
|
34
40
|
|
|
35
41
|
// This should never happen but we'll add it so we don't crash in unexpected situations
|