// From here: http://stackoverflow.com/a/24519813/3296811 const fixedPrint = function (type, args) { const indent = Math.ceil((REPL.line.length + 3) / process.stdout.columns); const text = util.format.apply(console, args); REPL.output.write('\n\x1B[' + indent + 'A\x1B[0J'); // No idea at all.... REPL.output.write(text + '\n'); REPL.output.write(Array(indent).join('\n\x1B[E')); REPL._refreshLine(); }
write(args) { let formattedStr = util.format.apply(this,arguments); if (this.isIndented()) { for (let i = 0; i < this._indentation; ++i) { this._str += ' '; } } this._str += formattedStr; return this.newline(); }
function log(args, logFunc, level, tag) { const date = new Date(); const eol = os.EOL; const message = util.format.apply(util, args); const logMessage = util.format('[%s @ %s] [%s] %s%s', level, moment(date).format('YYYY-MM-DD HH:mm:ss'), tag, message, eol); logFunc(logMessage); Storage.append({ fileName: 'punk.log', value: logMessage }, (error) => { if(error) { console.error('Failed to save log message.'); console.error(error); } }); }
function() { this._stream.queue( format.apply(null, arguments).trim() + '\n' ) }.bind(this)
var warn = function() { console.log('WARNING:', util.format.apply(null, arguments)); }
cliMessage (msg) { // do NOT modify this.code here - the messages will be disregarded if help is requested const argsLen = arguments.length const args = new Array((argsLen || 1) - 1) for (let i = 0; i < argsLen; ++i) { args[i] = arguments[i] // if any args are an array, join into string // this is a hack to get Node 12's util.format working like Node 10's // e.g. require('util').format("Value \"%s\" is invalid.", ["web", "docs"]) // Node 10: Value "web,docs" is invalid. // Node 12: Value "[ 'web', 'docs' ]" is invalid. if (Array.isArray(args[i])) { args[i] = args[i].join(',') } } this.messages.push(format.apply(null, args)) }
function defaultLog() { if (levels.indexOf(arguments[0]) >= levels.indexOf(level)) console.log(new Date().toJSON() + " - " + arguments[0] + ": CRAWLER %s", util.format.apply(util, Array.prototype.slice.call(arguments, 1))); }
function filter(args, level) { var message = util.format.apply(util.format, args); self.emitEvent('message:' + level, '[' + name + '] ' + message); }
var msg = util.format.apply(util, args);
function createLoggerFunction (level) { level = logLevels[level] if (!level || level < 1 || level > 5) { level = 3 // info } return function printlog () { var line = '' if (arguments.length === 1) { line = util.formatValue(arguments[0]) } else if (arguments.length === 2) { line = `${util.formatValue(arguments[0])} ${util.formatValue(arguments[1])}` } else { line = util.format.apply(util, arguments) } if (line.length >= 1024) { line = line.slice(0, 1024) + '...' } native.print(level, this.name, line) } }