summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/helpers/log.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-08-03 11:36:36 -0500
committerkpdecker <kpdecker@gmail.com>2015-08-03 11:37:49 -0500
commit9a49d350231edbe82c9982df9a99f39596fb96b7 (patch)
treec4c035fb66e73eb0dfe7e77b8b8f3ddc16068f83 /lib/handlebars/helpers/log.js
parentb664997dc37ab46eff678b802bb57c84160f46ad (diff)
downloadhandlebars.js-9a49d350231edbe82c9982df9a99f39596fb96b7.zip
handlebars.js-9a49d350231edbe82c9982df9a99f39596fb96b7.tar.gz
handlebars.js-9a49d350231edbe82c9982df9a99f39596fb96b7.tar.bz2
Improve logging API
Adds multiple variable support and the ability to set statement level logging semantics. This breaks that logger API, cleaning up the manner in which enums are set, but the other behaviors are backwards compatible. Fixes #956
Diffstat (limited to 'lib/handlebars/helpers/log.js')
-rw-r--r--lib/handlebars/helpers/log.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/handlebars/helpers/log.js b/lib/handlebars/helpers/log.js
index ab83604..4bde4a1 100644
--- a/lib/handlebars/helpers/log.js
+++ b/lib/handlebars/helpers/log.js
@@ -1,6 +1,19 @@
export default function(instance) {
- instance.registerHelper('log', function(message, options) {
- let level = options.data && options.data.level != null ? parseInt(options.data.level, 10) : 1;
- instance.log(level, message);
+ instance.registerHelper('log', function(/* message, options */) {
+ let args = [undefined],
+ options = arguments[arguments.length - 1];
+ for (let i = 0; i < arguments.length - 1; i++) {
+ args.push(arguments[i]);
+ }
+
+ let level = 1;
+ if (options.hash.level != null) {
+ level = options.hash.level;
+ } else if (options.data && options.data.level != null) {
+ level = options.data.level;
+ }
+ args[0] = level;
+
+ instance.log(... args);
});
}