Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
log.table = function (level, data, transform) {
if (arguments.length == 2) {
transform = data;
data = level;
level = 'data';
}
if (log.format().json) {
log.log(level, 'table', data);
} else {
var table = new Table();
table.LeftPadder = Table.LeftPadder;
table.padLeft = Table.padLeft;
table.RightPadder = Table.RightPadder;
table.padRight = Table.padRight;
if (data && data.forEach) {
data.forEach(function (item) { transform(table, item); table.newLine(); });
} else if (data) {
for (var item in data) {
transform(table, item);
table.newLine();
}
}
var lines = table.toString();
lines.substring(0, lines.length - 1).split('\n').forEach(function (line) {
log.log(level, line);