| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2f5616d commit 266cf37
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a | |||
| 19 | 19 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
| 20 | 20 | ||
| 21 | 21 | var debug = require('debug')('json-rules-engine'); | |
| 22 | + var verbose = require('debug')('json-rules-engine-verbose'); | ||
| 22 | 23 | ||
| 23 | 24 | /** | |
| 24 | 25 | * Fact results lookup | |
@@ -109,12 +110,12 @@ var Almanac = function () { | |||
| 109 | 110 | } | |
| 110 | 111 | ||
| 111 | 112 | cacheVal.then(function (val) { | |
| 112 | - return debug('almanac::factValue cache hit for fact:' + factId + ' cacheKey:' + cacheKey + ' value: ' + JSON.stringify(val) + '<' + (typeof val === 'undefined' ? 'undefined' : _typeof(val)) + '>'); | ||
| 113 | + return debug('almanac::factValue cache hit for fact:' + factId + ' value: ' + JSON.stringify(val) + '<' + (typeof val === 'undefined' ? 'undefined' : _typeof(val)) + '>'); | ||
| 113 | 114 | }); | |
| 114 | 115 | return _context.abrupt('return', cacheVal); | |
| 115 | 116 | ||
| 116 | 117 | case 6: | |
| 117 | - debug('almanac::factValue cache miss for fact:' + factId + ' using cacheKey:' + cacheKey + '; calculating'); | ||
| 118 | + verbose('almanac::factValue cache miss for fact:' + factId + '; calculating'); | ||
| 118 | 119 | return _context.abrupt('return', this._setFactValue(fact, params, fact.calculate(params, this))); | |
| 119 | 120 | ||
| 120 | 121 | case 8: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -238,6 +238,7 @@ var Engine = function (_EventEmitter) { | |||
| 238 | 238 | while (1) { | |
| 239 | 239 | switch (_context2.prev = _context2.next) { | |
| 240 | 240 | case 0: | |
| 241 | + debug('engine::run started'); | ||
| 241 | 242 | debug('engine::run runtimeFacts:', runtimeFacts); | |
| 242 | 243 | this.status = RUNNING; | |
| 243 | 244 | almanac = new _almanac2.default(this.facts, runtimeFacts); | |
@@ -255,11 +256,12 @@ var Engine = function (_EventEmitter) { | |||
| 255 | 256 | }); | |
| 256 | 257 | cursor.then(function () { | |
| 257 | 258 | _this4.status = FINISHED; | |
| 259 | + debug('engine::run completed'); | ||
| 258 | 260 | resolve(); | |
| 259 | 261 | }).catch(reject); | |
| 260 | 262 | })); | |
| 261 | 263 | ||
| 262 | - case 6: | ||
| 264 | + case 7: | ||
| 263 | 265 | case 'end': | |
| 264 | 266 | return _context2.stop(); | |
| 265 | 267 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de | |||
| 15 | 15 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | |
| 16 | 16 | ||
| 17 | 17 | var debug = require('debug')('json-rules-engine'); | |
| 18 | + var verbose = require('debug')('json-rules-engine-verbose'); | ||
| 18 | 19 | ||
| 19 | 20 | var Fact = function () { | |
| 20 | 21 | /** | |
@@ -109,7 +110,7 @@ var Fact = function () { | |||
| 109 | 110 | }], [{ | |
| 110 | 111 | key: 'hashFromObject', | |
| 111 | 112 | value: function hashFromObject(obj) { | |
| 112 | - debug('fact::hashFromObject generating cache key from:', obj); | ||
| 113 | + verbose('fact::hashFromObject generating cache key from:', obj); | ||
| 113 | 114 | return (0, _objectHash2.default)(obj); | |
| 114 | 115 | } | |
| 115 | 116 | }]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | 'use strict' | |
| 2 | 2 | ||
| 3 | 3 | let debug = require('debug')('json-rules-engine') | |
| 4 | + let verbose = require('debug')('json-rules-engine-verbose') | ||
| 4 | 5 | ||
| 5 | 6 | import Fact from './fact' | |
| 6 | 7 | ||
@@ -63,10 +64,10 @@ export default class Almanac { | |||
| 63 | 64 | let cacheKey = fact.getCacheKey(params) | |
| 64 | 65 | let cacheVal = cacheKey && this.factResultsCache.get(cacheKey) | |
| 65 | 66 | if (cacheVal) { | |
| 66 | - cacheVal.then(val => debug(`almanac::factValue cache hit for fact:${factId} cacheKey:${cacheKey} value: ${JSON.stringify(val)}<${typeof val}>`)) | ||
| 67 | + cacheVal.then(val => debug(`almanac::factValue cache hit for fact:${factId} value: ${JSON.stringify(val)}<${typeof val}>`)) | ||
| 67 | 68 | return cacheVal | |
| 68 | 69 | } | |
| 69 | - debug(`almanac::factValue cache miss for fact:${factId} using cacheKey:${cacheKey}; calculating`) | ||
| 70 | + verbose(`almanac::factValue cache miss for fact:${factId}; calculating`) | ||
| 70 | 71 | return this._setFactValue(fact, params, fact.calculate(params, this)) | |
| 71 | 72 | } | |
| 72 | 73 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -140,6 +140,7 @@ class Engine extends EventEmitter { | |||
| 140 | 140 | * @return {Promise} resolves when the engine has completed running | |
| 141 | 141 | */ | |
| 142 | 142 | async run (runtimeFacts = new Map()) { | |
| 143 | + debug(`engine::run started`) | ||
| 143 | 144 | debug(`engine::run runtimeFacts:`, runtimeFacts) | |
| 144 | 145 | this.status = RUNNING | |
| 145 | 146 | let almanac = new Almanac(this.facts, runtimeFacts) | |
@@ -156,6 +157,7 @@ class Engine extends EventEmitter { | |||
| 156 | 157 | }) | |
| 157 | 158 | cursor.then(() => { | |
| 158 | 159 | this.status = FINISHED | |
| 160 | + debug(`engine::run completed`) | ||
| 159 | 161 | resolve() | |
| 160 | 162 | }).catch(reject) | |
| 161 | 163 | }) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | import hash from 'object-hash' | |
| 4 | 4 | ||
| 5 | 5 | let debug = require('debug')('json-rules-engine') | |
| 6 | + let verbose = require('debug')('json-rules-engine-verbose') | ||
| 6 | 7 | ||
| 7 | 8 | class Fact { | |
| 8 | 9 | /** | |
@@ -56,7 +57,7 @@ class Fact { | |||
| 56 | 57 | * @return {string} MD5 string based on the hash'd object | |
| 57 | 58 | */ | |
| 58 | 59 | static hashFromObject (obj) { | |
| 59 | - debug(`fact::hashFromObject generating cache key from:`, obj) | ||
| 60 | + verbose(`fact::hashFromObject generating cache key from:`, obj) | ||
| 60 | 61 | return hash(obj) | |
| 61 | 62 | } | |
| 62 | 63 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments