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.
Files changed (2) hide show
  1. package/modules/logging.js +11 -5
  2. package/package.json +1 -1
@@ -15,21 +15,27 @@ const should_log = levels => {
15
15
 
16
16
  const add_trace = messages => {
17
17
 
18
- // Do nothing if we are not in a browser
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 as it is always the error message
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mentie",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Mentor's toolbelt",
5
5
  "type": "module",
6
6
  "main": "index.js",