@reldens/utils 0.49.0 → 0.50.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.
Files changed (2) hide show
  1. package/lib/logger.js +13 -8
  2. package/package.json +1 -1
package/lib/logger.js CHANGED
@@ -29,14 +29,13 @@ class Logger
29
29
  this.callback = false;
30
30
  this.forcedDisabled = Boolean(sc.get(context, 'RELDENS_LOGS_FORCED_DISABLED', false));
31
31
  this.addTimeStamp = Boolean(sc.get(context, 'RELDENS_LOGS_INCLUDE_TIMESTAMP', true));
32
- this.maxLogArgLength = sc.get(context, 'RELDENS_LOGS_MAX_ARGUMENT_LENGTH', 1000);
33
- this.maxStackTraceLength = sc.get(context, 'RELDENS_LOGS_MAX_STACK_TRACE_LENGTH', 2000);
32
+ this.maxLogArgLength = sc.get(context, 'RELDENS_LOGS_MAX_ARGUMENT_LENGTH', 0);
33
+ this.maxStackTraceLength = sc.get(context, 'RELDENS_LOGS_MAX_STACK_TRACE_LENGTH', 0);
34
+ this.applySanitizer = Boolean(sc.get(context, 'RELDENS_LOGS_APPLY_SANITIZER', false));
34
35
  }
35
36
 
36
37
  context()
37
38
  {
38
- // @NOTE: any change on this method could break Parcel and you will end up with the following error.
39
- // Failed to resolve module specifier "process"
40
39
  let context = process.env;
41
40
  if('undefined' !== typeof window){
42
41
  return window;
@@ -95,8 +94,11 @@ class Logger
95
94
  log(levelLabel, ...args)
96
95
  {
97
96
  let date = !this.addTimeStamp ? '' : (new Date()).toISOString().slice(0, 19).replace('T', ' ')+' - ';
98
- let sanitizedArgs = args.map(arg => sc.isString(arg) ? sc.cleanMessage(arg, this.maxLogArgLength) : arg);
99
- this.logWithCallback(date+levelLabel.toUpperCase()+' -', ...sanitizedArgs);
97
+ let processedArgs = args;
98
+ if(this.applySanitizer){
99
+ processedArgs = args.map(arg => sc.isString(arg) ? sc.cleanMessage(arg, this.maxLogArgLength) : arg);
100
+ }
101
+ this.logWithCallback(date+levelLabel.toUpperCase()+' -', ...processedArgs);
100
102
  if(-1 !== this.enableTraceFor().indexOf('all') || -1 !== this.enableTraceFor().indexOf(levelLabel)){
101
103
  if('function' !== typeof Error?.captureStackTrace){
102
104
  this.logWithCallback('Error.captureStackTrace is not available.', typeof Error?.captureStackTrace);
@@ -104,8 +106,11 @@ class Logger
104
106
  }
105
107
  let stackHolder = {};
106
108
  Error.captureStackTrace(stackHolder, levelLabel);
107
- let sanitizedStack = sc.cleanMessage(stackHolder.stack, this.maxStackTraceLength);
108
- this.logWithCallback(sanitizedStack);
109
+ let processedStack = stackHolder.stack;
110
+ if(this.applySanitizer){
111
+ processedStack = sc.cleanMessage(stackHolder.stack, this.maxStackTraceLength);
112
+ }
113
+ this.logWithCallback(processedStack);
109
114
  }
110
115
  return this;
111
116
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/utils",
3
3
  "scope": "@reldens",
4
- "version": "0.49.0",
4
+ "version": "0.50.0",
5
5
  "description": "Reldens - Utils",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",