Skip to content

Commit

Permalink
fix(file-system/logger): don't use spread operator to support nodejs 4
Browse files Browse the repository at this point in the history
closes #527
  • Loading branch information
JeroenVinke committed Mar 8, 2017
1 parent d6f0ada commit ed6eb25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/file-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ exports.resolve = function(path) {
return nodePath.resolve(path);
};

exports.join = function(...segments) {
return nodePath.join.apply(this, segments);
exports.join = function() {
return nodePath.join.apply(this, Array.prototype.slice.call(arguments));
};

exports.statSync = function (path) {
Expand Down
24 changes: 13 additions & 11 deletions lib/logger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
const UI = require('./ui').UI;

exports.Logger = class {
Expand All @@ -8,27 +9,28 @@ exports.Logger = class {
this.ui = ui;
}

debug(logger, message, ...rest){
this.log(logger, 'DEBUG', message, rest);
debug(logger, message){
this.log(logger, 'DEBUG', message, arguments);
}

info(logger, message, ...rest){
this.log(logger, 'INFO', message, rest);
info(logger, message){
this.log(logger, 'INFO', message, arguments);
}

warn(logger, message, ...rest){
this.log(logger, 'WARN', message, rest);
warn(logger, message){
this.log(logger, 'WARN', message, arguments);
}

error(logger, message, ...rest){
this.log(logger, 'ERROR', message, rest);
error(logger, message){
this.log(logger, 'ERROR', message, arguments);
}

log(logger, level, message, rest) {
let msg = `${level} [${logger.id}] ${message}`;

if (rest.length > 0) {
msg += ` ${rest.map(x => JSON.stringify(x)).join(' ')}`;
let args = Array.prototype.slice.call(rest, 2);

if (args.length > 0) {
msg += ` ${args.map(x => JSON.stringify(x)).join(' ')}`;
}

this.ui.log(msg);
Expand Down

0 comments on commit ed6eb25

Please sign in to comment.