-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathlog.js
More file actions
30 lines (27 loc) · 833 Bytes
/
log.js
File metadata and controls
30 lines (27 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export default function (instance) {
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;
// Only add depth to args if it's explicitly provided
let depth;
if (options.hash.depth != null) {
depth = options.hash.depth;
} else if (options.data && options.data.depth != null) {
depth = options.data.depth;
}
if (depth != null) {
args.splice(1, 0, depth);
}
instance.log(...args);
});
}