'use strict'; var path = require("path"); var chalk = require("chalk"); var spy = require("through2-spy"); var fancyLog = require("fancy-log"); var padWidth = 5; var typeColors = { error: "red", warn: "yellow", info: "cyan", debug: "gray" }; function hexify(buff) { var bytes = []; for (var i = 0; i < buff.length; i++) { bytes.push(buff.toString("hex", i, i + 1)); } return bytes; } module.exports = function namedLog(name) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; var prefix = "[" + chalk.green(name) + "]"; function createLog(type) { var prefixes = [prefix]; if (type) { var typeColor = typeColors[type] != null ? typeColors[type] : "white"; var typePrefix = "[" + chalk[typeColor](type) + "]"; prefixes.push(typePrefix); } return function log() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } fancyLog.apply(null, prefixes.concat(args)); }; } return { debug: createLog("debug"), info: createLog("info"), warn: createLog("warn"), error: createLog("error"), log: createLog(), stream: function stream() { var _this = this; return spy.obj(function (file) { var shortPath = void 0, firstBytes = void 0, suffix = void 0; var byteLimit = options.byteLimit != null ? options.byteLimit : 20; if (options.basePath != null) { shortPath = path.relative(options.basePath, file.path); } else { shortPath = path.basename(file.path); } if (file.contents.length <= byteLimit) { firstBytes = file.contents; suffix = ""; } else { firstBytes = file.contents.slice(0, byteLimit); suffix = " ..."; } _this.info(">"); }); } }; };