diff options
| author | Pitu <[email protected]> | 2018-09-16 00:55:41 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2018-09-16 00:55:41 -0300 |
| commit | a42cf4400eb00d3e476e29223d9c3587d61a105a (patch) | |
| tree | cc09b5e0c75179d19b4e77dac28e0201ede9fa02 /src/api/utils/Log.js | |
| parent | Base structures (diff) | |
| download | host.fuwn.me-a42cf4400eb00d3e476e29223d9c3587d61a105a.tar.xz host.fuwn.me-a42cf4400eb00d3e476e29223d9c3587d61a105a.zip | |
Utils
Diffstat (limited to 'src/api/utils/Log.js')
| -rw-r--r-- | src/api/utils/Log.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/api/utils/Log.js b/src/api/utils/Log.js new file mode 100644 index 0000000..6753f9e --- /dev/null +++ b/src/api/utils/Log.js @@ -0,0 +1,37 @@ +const chalk = require('chalk'); +const { dump } = require('dumper.js'); + +class Log { + static info(args) { + if (this.checkIfArrayOrObject(args)) dump(args); + else console.log(args); // eslint-disable-line no-console + } + + static success(args) { + if (this.checkIfArrayOrObject(args)) dump(args); + else console.log(chalk.green(args)); // eslint-disable-line no-console + } + + static warn(args) { + if (this.checkIfArrayOrObject(args)) dump(args); + else console.log(chalk.yellow(args)); // eslint-disable-line no-console + } + + static error(args) { + if (this.checkIfArrayOrObject(args)) dump(args); + else console.log(chalk.red(args)); // eslint-disable-line no-console + } + + /* + static dump(args) { + dump(args); + } + */ + + static checkIfArrayOrObject(thing) { + if (typeof thing === typeof [] || typeof thing === typeof {}) return true; + return false; + } +} + +module.exports = Log; |