62 lines
7.6 KiB
JavaScript
62 lines
7.6 KiB
JavaScript
/// <reference path="./typings/main.d.ts" />
|
|
"use strict";
|
|
var plugins = require("./beautylog.plugins");
|
|
var localBl = {
|
|
dirPrefix: plugins.clc.bgXterm(39).xterm(231).bold(' DIR ') + ' ',
|
|
errorPrefix: ' Error: '.bgRed.white.bold + ' ',
|
|
infoPrefix: plugins.clc.bgXterm(198).xterm(231).bold(' INFO ') + ' ',
|
|
normalPrefix: ' Log: '.bgCyan.white.bold + ' ',
|
|
okPrefix: ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' ',
|
|
successPrefix: ' Success: '.bgGreen.white.bold + ' ',
|
|
warnPrefix: ' '.bgYellow + ' Warn: '.bgBlack.yellow.bold + ' '
|
|
};
|
|
/**
|
|
*
|
|
* @param logText
|
|
* @param logType
|
|
* @returns {boolean}
|
|
*/
|
|
var logFunction = function (logText, logType) {
|
|
if (logText === void 0) { logText = 'empty log'; }
|
|
if (logType === void 0) { logType = 'normal'; }
|
|
try {
|
|
switch (logType) {
|
|
case 'dir':
|
|
logText = localBl.dirPrefix + plugins.clc.xterm(26)(logText);
|
|
break;
|
|
case 'error':
|
|
logText = localBl.errorPrefix + logText.red.bold;
|
|
break;
|
|
case 'info':
|
|
logText = localBl.infoPrefix + plugins.clc.xterm(198)(logText);
|
|
break;
|
|
case 'normal':
|
|
logText = localBl.normalPrefix + logText.cyan.bold;
|
|
break;
|
|
case 'ok':
|
|
logText = localBl.okPrefix + logText.bold;
|
|
break;
|
|
case 'success':
|
|
logText = localBl.successPrefix + logText.green.bold;
|
|
break;
|
|
case 'warn':
|
|
logText = localBl.warnPrefix + logText.bold;
|
|
break;
|
|
case 'log':
|
|
default:
|
|
logText.blue.bold;
|
|
console.log(('unknown logType for "' + logText + '"').red.bold);
|
|
break;
|
|
}
|
|
console.log(logText);
|
|
return true;
|
|
}
|
|
catch (error) {
|
|
console.log(localBl.errorPrefix + 'You seem to have tried logging something strange'.red.bold + error);
|
|
return false;
|
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nJlYWs7XG4gICAgICAgICAgICBjYXNlICdpbmZvJzpcbiAgICAgICAgICAgICAgICBsb2dUZXh0ID0gbG9jYWxCbC5pbmZvUHJlZml4ICsgcGx1Z2lucy5jbGMueHRlcm0oMTk4KShsb2dUZXh0KTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ25vcm1hbCc6XG4gICAgICAgICAgICAgICAgbG9nVGV4dCA9IGxvY2FsQmwubm9ybWFsUHJlZml4ICsgbG9nVGV4dC5jeWFuLmJvbGQ7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlICdvayc6XG4gICAgICAgICAgICAgICAgbG9nVGV4dCA9IGxvY2FsQmwub2tQcmVmaXggKyBsb2dUZXh0LmJvbGQ7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlICdzdWNjZXNzJzpcbiAgICAgICAgICAgICAgICBsb2dUZXh0ID0gbG9jYWxCbC5zdWNjZXNzUHJlZml4ICsgbG9nVGV4dC5ncmVlbi5ib2xkO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnd2Fybic6XG4gICAgICAgICAgICAgICAgbG9nVGV4dCA9IGxvY2FsQmwud2FyblByZWZpeCArIGxvZ1RleHQuYm9sZDtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ2xvZyc6XG4gICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgIGxvZ1RleHQuYmx1ZS5ib2xkO1xuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKCgndW5rbm93biBsb2dUeXBlIGZvciBcIicgKyBsb2dUZXh0ICsgJ1wiJykucmVkLmJvbGQpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgICAgIGNvbnNvbGUubG9nKGxvZ1RleHQpO1xuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG4gICAgY2F0Y2ggKGVycm9yKSB7XG4gICAgICAgIGNvbnNvbGUubG9nKGxvY2FsQmwuZXJyb3JQcmVmaXggKyAnWW91IHNlZW0gdG8gaGF2ZSB0cmllZCBsb2dnaW5nIHNvbWV0aGluZyBzdHJhbmdlJy5yZWQuYm9sZCArIGVycm9yKTtcbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH1cbn07XG5leHBvcnQgPSBsb2dGdW5jdGlvbjsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|