Commit 65757228e0649a2a80c5566740c5245b3b472ed3

Authored by Adhidarma Hadiwinoto
1 parent 124f020a5d
Exists in master

debug

Showing 1 changed file with 8 additions and 0 deletions Side-by-side Diff

1 1 "use strict";
2 2  
  3 +function logOnDebug(msg) {
  4 + if (process.env.KOMODO_SDK_DEBUG_RC_FROM_MSG) {
  5 + console.log(msg);
  6 + }
  7 +}
  8 +
3 9 function run(msg, rules) {
4 10 if (typeof msg !== 'string') return;
5 11 if (!rules) return;
... ... @@ -9,8 +15,10 @@ function run(msg, rules) {
9 15 for(let i = 0; i < rules_count; i++) {
10 16 const rule = rules[i];
11 17  
  18 + logOnDebug('RC-FROM-MSG: checking with rule: ' + JSON.stringify(rule));
12 19 const re = (typeof rule.flags === 'string') ? new RegExp(rule.pattern, rule.flags) : new RegExp(rule.pattern);
13 20 if (msg.search(re) > 0) {
  21 + logOnDebug('RC-FROM-MSG: match with rule: ' + JSON.stringify(rule));
14 22 return rule.rc || rule.result;
15 23 }
16 24 }