app/assets/javascripts/logging_utils.js.coffee in hqmf2js-1.1.0 vs app/assets/javascripts/logging_utils.js.coffee in hqmf2js-1.2.0

- old
+ new

@@ -1,9 +1,13 @@ class @Logger @logger: [] + @rationale: {} @info: (string) -> @logger.push("#{Logger.indent()}#{string}") + @record: (id, result) -> + if result? and typeof(result.isTrue) == 'function' + @rationale[id] = result.isTrue() @enabled: true @initialized: false @indentCount = 0 @indent: -> indent = '' @@ -38,16 +42,21 @@ , []).join(',')+"]" @enableMeasureLogging = (hqmfjs) -> _.each(_.functions(hqmfjs), (method) -> - hqmfjs[method] = _.wrap(hqmfjs[method], (func, patient) -> + hqmfjs[method] = _.wrap(hqmfjs[method], (func) -> + + args = Array.prototype.slice.call(arguments,1) + Logger.info("#{method}:") Logger.indentCount++ - result = func(patient) + result = func.apply(this, args) + Logger.indentCount-- Logger.info("#{method} -> #{Logger.asBoolean(result)}") + Logger.record(method,result) return result; ); ); @enableLogging =-> @@ -71,16 +80,10 @@ return result;); ); hQuery.CodedEntryList.prototype.match = _.wrap(hQuery.CodedEntryList.prototype.match, (func, codeSet, start, end) -> - - # if (codeSet) - # Logger.info("matching: codeSets(#{_.keys(codeSet).join(",")}), #{start}, #{end}") - # else - # Logger.info("matching: WARNING: CODE SETS ARE NULL, #{start}, #{end}") - func = _.bind(func, this, codeSet,start,end) result = func(codeSet,start,end) Logger.info("matched -> #{Logger.stringify(result)}") return result; ); @@ -96,39 +99,43 @@ Logger.info("called atLeastOneTrue(#{args}):") Logger.indentCount++ result = func.apply(this, args) Logger.indentCount-- Logger.info("atLeastOneTrue -> #{result}") + Logger.record("precondition_#{args[0]}",result) result ) @allTrue = _.wrap(@allTrue, (func) -> args = Array.prototype.slice.call(arguments,1) Logger.info("called allTrue(#{args}):") Logger.indentCount++ result = func.apply(this, args) Logger.indentCount-- Logger.info("allTrue -> #{result}") + Logger.record("precondition_#{args[0]}",result) result ) @allFalse = _.wrap(@allFalse, (func) -> args = Array.prototype.slice.call(arguments,1) Logger.info("called allFalse(#{args}):") Logger.indentCount++ result = func.apply(this, args) Logger.indentCount-- Logger.info("allFalse -> #{result}") + Logger.record("precondition_#{args[0]}",result) result ) @atLeastOneFalse = _.wrap(@atLeastOneFalse, (func) -> args = Array.prototype.slice.call(arguments,1) Logger.info("called atLeastOneFalse(#{args}):") Logger.indentCount++ result = func.apply(this, args) Logger.indentCount-- Logger.info("atLeastOneFalse -> #{result}") + Logger.record("precondition_#{args[0]}",result) result ) @eventsMatchBounds = _.wrap(@eventsMatchBounds, (func, events, bounds, methodName, range) -> args = Array.prototype.slice.call(arguments,1)