Use pluggable logger rather the puts
This commit is contained in:
@@ -99,6 +99,15 @@ Handlebars.registerHelper('if', function(context, fn, inverse) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Handlebars.logger = {
|
||||||
|
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
||||||
|
|
||||||
|
// override in the host environment
|
||||||
|
log: function(level, str) {},
|
||||||
|
}
|
||||||
|
|
||||||
|
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
||||||
|
|
||||||
// END(BROWSER)
|
// END(BROWSER)
|
||||||
|
|
||||||
exports.Handlebars = Handlebars;
|
exports.Handlebars = Handlebars;
|
||||||
|
|||||||
@@ -250,8 +250,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|||||||
|
|
||||||
this.compileChildren(environment);
|
this.compileChildren(environment);
|
||||||
|
|
||||||
//puts(environment.disassemble());
|
Handlebars.log(Handlebars.logger.DEBUG, environment.disassemble() + "\n\n");
|
||||||
//puts("")
|
|
||||||
|
|
||||||
var opcodes = environment.opcodes;
|
var opcodes = environment.opcodes;
|
||||||
var opcode, name;
|
var opcode, name;
|
||||||
@@ -315,8 +314,7 @@ Handlebars.JavaScriptCompiler = function() {};
|
|||||||
var fn = Function.apply(this, params);
|
var fn = Function.apply(this, params);
|
||||||
fn.displayName = "Handlebars.js"
|
fn.displayName = "Handlebars.js"
|
||||||
|
|
||||||
//puts(fn.toString())
|
Handlebars.log(Handlebars.logger.DEBUG, fn.toString() + "\n\n");
|
||||||
//puts("")
|
|
||||||
|
|
||||||
container.render = fn;
|
container.render = fn;
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,16 @@ module Handlebars
|
|||||||
Handlebars::Spec.js_load('lib/handlebars/utils.js')
|
Handlebars::Spec.js_load('lib/handlebars/utils.js')
|
||||||
Handlebars::Spec.js_load('lib/Handlebars/vm.js')
|
Handlebars::Spec.js_load('lib/Handlebars/vm.js')
|
||||||
Handlebars::Spec.js_load('lib/handlebars.js')
|
Handlebars::Spec.js_load('lib/handlebars.js')
|
||||||
|
|
||||||
|
context["Handlebars"]["logger"]["level"] = ENV["DEBUG_JS"] ? context["Handlebars"]["logger"][ENV["DEBUG_JS"]] : 4
|
||||||
|
|
||||||
|
context["Handlebars"]["logger"]["log"] = proc do |level, str|
|
||||||
|
logger_level = context["Handlebars"]["logger"]["level"]
|
||||||
|
|
||||||
|
if logger_level <= level
|
||||||
|
puts str
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user