Skip to content

Replace debug package with console.log #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.3.5 / 2019-04-26
* Replace debug with vanilla console.log

2.3.4 / 2019-04-26
* Use Array.isArray instead of instanceof to test Array parameters to address edge cases

Expand Down
4 changes: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
},
"dependencies": {
"clone": "^2.1.2",
"debug": "^4.1.1",
"events": "^3.0.0",
"lodash.isobjectlike": "^4.0.0",
"object-hash": "^1.3.1",
Expand Down
12 changes: 5 additions & 7 deletions src/almanac.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import Fact from './fact'
import { UndefinedFactError } from './errors'
import debug from './debug'

let debug = require('debug')('json-rules-engine')
let verbose = require('debug')('json-rules-engine-verbose')
let selectn = require('selectn')
let isObjectLike = require('lodash.isobjectlike')
let warn = require('debug')('json-rules-engine:warn')
import selectn from 'selectn'
import isObjectLike from 'lodash.isobjectlike'

/**
* Fact results lookup
Expand Down Expand Up @@ -98,7 +96,7 @@ export default class Almanac {
factValuePromise = Promise.resolve(cacheVal)
debug(`almanac::factValue cache hit for fact:${factId}`)
} else {
verbose(`almanac::factValue cache miss for fact:${factId}; calculating`)
debug(`almanac::factValue cache miss for fact:${factId}; calculating`)
factValuePromise = this._setFactValue(fact, params, fact.calculate(params, this))
}
}
Expand All @@ -110,7 +108,7 @@ export default class Almanac {
debug(`condition::evaluate extracting object property ${path}, received: ${pathValue}`)
return pathValue
} else {
warn(`condition::evaluate could not compute object path(${path}) of non-object: ${factValue} <${typeof factValue}>; continuing with ${factValue}`)
debug(`condition::evaluate could not compute object path(${path}) of non-object: ${factValue} <${typeof factValue}>; continuing with ${factValue}`)
return factValue
}
})
Expand Down
4 changes: 2 additions & 2 deletions src/condition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

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

export default class Condition {
constructor (properties) {
Expand Down
5 changes: 5 additions & 0 deletions src/debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function debug (message) {
if (process.env.DEBUG && process.env.DEBUG.match(/json-rules-engine/)) {
console.log(message)
}
}
3 changes: 1 addition & 2 deletions src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import Almanac from './almanac'
import { EventEmitter } from 'events'
import { SuccessEventFact } from './engine-facts'
import defaultOperators from './engine-default-operators'

let debug = require('debug')('json-rules-engine')
import debug from './debug'

export const READY = 'READY'
export const RUNNING = 'RUNNING'
Expand Down
3 changes: 0 additions & 3 deletions src/fact.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import hash from 'object-hash'

let verbose = require('debug')('json-rules-engine-verbose')

class Fact {
/**
* Returns a new fact instance
Expand Down Expand Up @@ -66,7 +64,6 @@ class Fact {
* @return {string} MD5 string based on the hash'd object
*/
static hashFromObject (obj) {
verbose(`fact::hashFromObject generating cache key from:`, obj)
return hash(obj)
}

Expand Down
3 changes: 1 addition & 2 deletions src/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import Condition from './condition'
import RuleResult from './rule-result'
import { EventEmitter } from 'events'

let debug = require('debug')('json-rules-engine')
import debug from './debug'

class Rule extends EventEmitter {
/**
Expand Down