-
Notifications
You must be signed in to change notification settings - Fork 1
/
logger.js
66 lines (64 loc) · 2.61 KB
/
logger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
/* eslint-disable linebreak-style */
const chalk = require('chalk');
var isHexcolor = require('is-hexcolor');
var getText = function(/** @type {string[]} */ ...Data) {
var Main = (Data.splice(0,1)).toString();
for (let i = 0; i < Data.length; i++) Main = Main.replace(RegExp(`%${i + 1}`, 'g'), Data[i]);
return Main;
};
/**
* @param {any} obj
*/
function getType(obj) {
return Object.prototype.toString.call(obj).slice(8, -1);
}
module.exports = {
Normal: function(/** @type {string} */ Str, /** @type {() => any} */ Data ,/** @type {() => void} */ Callback) {
if (isHexcolor(global.Fca.Require.FastConfig.MainColor) != true) {
this.Warning(getText(global.Fca.Require.Language.Index.InvaildMainColor,global.Fca.Require.FastConfig.MainColor),process.exit(0));
}
else console.log(chalk.hex(global.Fca.Require.FastConfig.MainColor).bold(`${global.Fca.Require.FastConfig.MainName || '【𝐓𝐄𝐀𝐌-𝐀𝐓𝐅】->'} > `) + Str);
if (getType(Data) == 'Function' || getType(Data) == 'AsyncFunction') {
return Data();
}
if (Data) {
return Data;
}
if (getType(Callback) == 'Function' || getType(Callback) == 'AsyncFunction') {
Callback();
}
else return Callback;
},
Warning: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
console.log(chalk.magenta.bold('[ FCA-WARNING ] > ') + chalk.yellow(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
},
Error: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
if (!str) {
console.log(chalk.magenta.bold('[ FCA-ERROR ] > ') + chalk.red("Already Faulty, Please Contact: Facebook.com/Lazic.Kanzu"));
}
console.log(chalk.magenta.bold('[ FCA-ERROR ] > ') + chalk.red(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
},
Success: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
console.log(chalk.hex('#9900FF').bold(`${global.Fca.Require.FastConfig.MainName || '【𝐓𝐄𝐀𝐌-𝐀𝐓𝐅】->'} > `) + chalk.green(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
},
Info: function(/** @type {unknown} */ str, /** @type {() => void} */ callback) {
console.log(chalk.hex('#9900FF').bold(`${global.Fca.Require.FastConfig.MainName || '【𝐓𝐄𝐀𝐌-𝐀𝐓𝐅】->'} > `) + chalk.blue(str));
if (getType(callback) == 'Function' || getType(callback) == 'AsyncFunction') {
callback();
}
else return callback;
}
};