log - fallback
This commit is contained in:
parent
db9b974389
commit
183f3b660c
@ -1,11 +1,3 @@
|
||||
/*
|
||||
* This file is part of the authRxbn eco-system.
|
||||
*
|
||||
* (c) Ruben Meyer <contact@rxbn.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
var methods = {};
|
||||
let fs = require('fs');
|
||||
let util = require('util');
|
||||
@ -52,12 +44,19 @@ newLine = (prefix, obj) => {
|
||||
// typeof obj == "undefined"
|
||||
// typeof obj == "function"
|
||||
}
|
||||
};
|
||||
|
||||
fallback = (fn, ...data) => {
|
||||
if(data.length == 1) data = data[0];
|
||||
|
||||
fn.apply(null, data);
|
||||
}
|
||||
|
||||
|
||||
// LOG | INFO
|
||||
methods.log = (...data) => {
|
||||
global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
if(global['modules'].cli) global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
else fallback(console.log, data);
|
||||
|
||||
if(data.length == 1) data = data[0];
|
||||
newLine(" [LOG]", data);
|
||||
@ -66,7 +65,8 @@ methods.info = methods.log;
|
||||
|
||||
// WARNING
|
||||
methods.warn = (...data) => {
|
||||
global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
if(global['modules'].cli) global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
else fallback(console.warn, data);
|
||||
|
||||
if(data.length == 1) data = data[0];
|
||||
newLine(" [WARN]", data);
|
||||
@ -74,7 +74,8 @@ methods.warn = (...data) => {
|
||||
|
||||
// ERROR
|
||||
methods.error = (...data) => {
|
||||
global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
if(global['modules'].cli) global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
else fallback(console.error, data);
|
||||
|
||||
if(data.length == 1) data = data[0];
|
||||
newLine("[ERROR]", data);
|
||||
@ -84,7 +85,8 @@ methods.err = methods.error;
|
||||
// DEBUG
|
||||
methods.debug = (...data) => {
|
||||
if(global['gds'].debug) {
|
||||
global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
if(global['modules'].cli) global['modules'].cli.log.apply(global['modules'].cli, data);
|
||||
else fallback(console.log, data);
|
||||
|
||||
if(data.length == 1) data = data[0];
|
||||
newLine("[DEBUG]", data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user