Skip to content

Commit 8711ec9

Browse files
authored
Merge pull request #130 from CacheControl/remove-debug
Replace debug package with console.log
2 parents 5dad489 + 747d668 commit 8711ec9

9 files changed

+20
-18
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.3.5 / 2019-04-26
2+
* Replace debug with vanilla console.log
3+
14
2.3.4 / 2019-04-26
25
* Use Array.isArray instead of instanceof to test Array parameters to address edge cases
36

Diff for: package-lock.json

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
},
6666
"dependencies": {
6767
"clone": "^2.1.2",
68-
"debug": "^4.1.1",
6968
"events": "^3.0.0",
7069
"lodash.isobjectlike": "^4.0.0",
7170
"object-hash": "^1.3.1",

Diff for: src/almanac.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
import Fact from './fact'
44
import { UndefinedFactError } from './errors'
5+
import debug from './debug'
56

6-
let debug = require('debug')('json-rules-engine')
7-
let verbose = require('debug')('json-rules-engine-verbose')
8-
let selectn = require('selectn')
9-
let isObjectLike = require('lodash.isobjectlike')
10-
let warn = require('debug')('json-rules-engine:warn')
7+
import selectn from 'selectn'
8+
import isObjectLike from 'lodash.isobjectlike'
119

1210
/**
1311
* Fact results lookup
@@ -98,7 +96,7 @@ export default class Almanac {
9896
factValuePromise = Promise.resolve(cacheVal)
9997
debug(`almanac::factValue cache hit for fact:${factId}`)
10098
} else {
101-
verbose(`almanac::factValue cache miss for fact:${factId}; calculating`)
99+
debug(`almanac::factValue cache miss for fact:${factId}; calculating`)
102100
factValuePromise = this._setFactValue(fact, params, fact.calculate(params, this))
103101
}
104102
}
@@ -110,7 +108,7 @@ export default class Almanac {
110108
debug(`condition::evaluate extracting object property ${path}, received: ${pathValue}`)
111109
return pathValue
112110
} else {
113-
warn(`condition::evaluate could not compute object path(${path}) of non-object: ${factValue} <${typeof factValue}>; continuing with ${factValue}`)
111+
debug(`condition::evaluate could not compute object path(${path}) of non-object: ${factValue} <${typeof factValue}>; continuing with ${factValue}`)
114112
return factValue
115113
}
116114
})

Diff for: src/condition.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

3-
let debug = require('debug')('json-rules-engine')
4-
let isObjectLike = require('lodash.isobjectlike')
3+
import debug from './debug'
4+
import isObjectLike from 'lodash.isobjectlike'
55

66
export default class Condition {
77
constructor (properties) {

Diff for: src/debug.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default function debug (message) {
2+
if (process.env.DEBUG && process.env.DEBUG.match(/json-rules-engine/)) {
3+
console.log(message)
4+
}
5+
}

Diff for: src/engine.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import Almanac from './almanac'
77
import { EventEmitter } from 'events'
88
import { SuccessEventFact } from './engine-facts'
99
import defaultOperators from './engine-default-operators'
10-
11-
let debug = require('debug')('json-rules-engine')
10+
import debug from './debug'
1211

1312
export const READY = 'READY'
1413
export const RUNNING = 'RUNNING'

Diff for: src/fact.js

-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import hash from 'object-hash'
44

5-
let verbose = require('debug')('json-rules-engine-verbose')
6-
75
class Fact {
86
/**
97
* Returns a new fact instance
@@ -66,7 +64,6 @@ class Fact {
6664
* @return {string} MD5 string based on the hash'd object
6765
*/
6866
static hashFromObject (obj) {
69-
verbose(`fact::hashFromObject generating cache key from:`, obj)
7067
return hash(obj)
7168
}
7269

Diff for: src/rule.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import Condition from './condition'
44
import RuleResult from './rule-result'
55
import { EventEmitter } from 'events'
6-
7-
let debug = require('debug')('json-rules-engine')
6+
import debug from './debug'
87

98
class Rule extends EventEmitter {
109
/**

0 commit comments

Comments
 (0)