@yuneta/gobj-js 7.13.5 → 7.13.7

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.
@@ -385,7 +385,7 @@ var gobjJs = (function(exports) {
385
385
  function tab() {
386
386
  return " ".repeat(Math.max(1, __inside__ * 2));
387
387
  }
388
- var __trace_machine_format__ = 0;
388
+ var __trace_machine_format__ = 1;
389
389
  function gobj_set_trace_machine_format(format) {
390
390
  __trace_machine_format__ = Number(format) === 1 ? 1 : 0;
391
391
  }
@@ -3017,6 +3017,19 @@ var gobjJs = (function(exports) {
3017
3017
  function set_console_log_enabled(enabled) {
3018
3018
  __console_output_enabled__ = enabled ? true : false;
3019
3019
  }
3020
+ var __console_log_filter__ = null;
3021
+ function set_console_log_filter(fn) {
3022
+ __console_log_filter__ = typeof fn === "function" ? fn : null;
3023
+ }
3024
+ function console_wants(level, msg) {
3025
+ if (!__console_output_enabled__) return false;
3026
+ if (!__console_log_filter__) return true;
3027
+ try {
3028
+ return __console_log_filter__(level, msg) ? true : false;
3029
+ } catch (e) {
3030
+ return true;
3031
+ }
3032
+ }
3020
3033
  var __in_log_callback__ = false;
3021
3034
  function emit_log_callback(level, msg, hora) {
3022
3035
  if (__log_callback__ && !__in_log_callback__) {
@@ -3064,9 +3077,9 @@ var gobjJs = (function(exports) {
3064
3077
  let hora = current_timestamp();
3065
3078
  if (f_error) {
3066
3079
  if (f_error === _console.error) {
3067
- if (__console_output_enabled__) f_error("%c" + hora + " ERROR: " + String(msg), "color:red");
3080
+ if (console_wants("error", msg)) f_error("%c" + hora + " ERROR: " + String(msg), "color:red");
3068
3081
  } else {
3069
- if (__console_output_enabled__) _console.error("%c" + hora + " ERROR: " + String(msg), "color:red");
3082
+ if (console_wants("error", msg)) _console.error("%c" + hora + " ERROR: " + String(msg), "color:red");
3070
3083
  f_error(`${hora} ERROR: ${String(msg)}`);
3071
3084
  }
3072
3085
  }
@@ -3077,9 +3090,9 @@ var gobjJs = (function(exports) {
3077
3090
  let hora = current_timestamp();
3078
3091
  if (f_warning) {
3079
3092
  if (f_warning === _console.warn) {
3080
- if (__console_output_enabled__) f_warning("%c" + hora + " WARNING: " + String(msg), "color:yellow");
3093
+ if (console_wants("warning", msg)) f_warning("%c" + hora + " WARNING: " + String(msg), "color:yellow");
3081
3094
  } else {
3082
- if (__console_output_enabled__) _console.warn("%c" + hora + " WARNING: " + String(msg), "color:yellow");
3095
+ if (console_wants("warning", msg)) _console.warn("%c" + hora + " WARNING: " + String(msg), "color:yellow");
3083
3096
  f_warning(`${hora} WARNING: ${String(msg)}`);
3084
3097
  }
3085
3098
  }
@@ -3089,7 +3102,7 @@ var gobjJs = (function(exports) {
3089
3102
  let msg = format_log(format);
3090
3103
  let hora = current_timestamp();
3091
3104
  if (f_info) {
3092
- if (__console_output_enabled__) f_info("%c" + hora + " INFO: " + String(msg), "color:cyan");
3105
+ if (console_wants("info", msg)) f_info("%c" + hora + " INFO: " + String(msg), "color:cyan");
3093
3106
  }
3094
3107
  emit_log_callback("info", msg, hora);
3095
3108
  }
@@ -3097,7 +3110,7 @@ var gobjJs = (function(exports) {
3097
3110
  let msg = format_log(format);
3098
3111
  let hora = current_timestamp();
3099
3112
  if (f_debug) {
3100
- if (__console_output_enabled__) f_debug("%c" + hora + " DEBUG: " + String(msg), "color:silver");
3113
+ if (console_wants("debug", msg)) f_debug("%c" + hora + " DEBUG: " + String(msg), "color:silver");
3101
3114
  }
3102
3115
  emit_log_callback("debug", msg, hora);
3103
3116
  }
@@ -3105,12 +3118,12 @@ var gobjJs = (function(exports) {
3105
3118
  let msg = format_log(format);
3106
3119
  let hora = current_timestamp();
3107
3120
  if (f_debug) {
3108
- if (__console_output_enabled__) f_debug("%c" + hora + " MSG: " + String(msg), "color:cyan");
3121
+ if (console_wants("msg", msg)) f_debug("%c" + hora + " MSG: " + String(msg), "color:cyan");
3109
3122
  }
3110
3123
  emit_log_callback("msg", msg, hora);
3111
3124
  }
3112
3125
  function trace_json(jn, msg) {
3113
- if (__console_output_enabled__) {
3126
+ if (console_wants("json", msg)) {
3114
3127
  if (msg) window.console.warn("=====> " + msg);
3115
3128
  window.console.dir(jn);
3116
3129
  }
@@ -6862,6 +6875,7 @@ var gobjJs = (function(exports) {
6862
6875
  exports.sdata_flag_t = sdata_flag_t;
6863
6876
  exports.send_http_json_post = send_http_json_post;
6864
6877
  exports.set_console_log_enabled = set_console_log_enabled;
6878
+ exports.set_console_log_filter = set_console_log_filter;
6865
6879
  exports.set_log_callback = set_log_callback;
6866
6880
  exports.set_remote_log_functions = set_remote_log_functions;
6867
6881
  exports.set_timeout = set_timeout;