Skip to content

Instantly share code, notes, and snippets.

@null4bl3
Created August 9, 2018 11:01
Show Gist options
  • Save null4bl3/64f8da2c1f2a206cf26e6d1b5b3f486a to your computer and use it in GitHub Desktop.
Save null4bl3/64f8da2c1f2a206cf26e6d1b5b3f486a to your computer and use it in GitHub Desktop.
let chalk = require('chalk');
module.exports = function (app) {
/**
* CLIENT INTERACTION SYSTEM LOG
*
* @param {*} _message
* @param {*} _action
* @param {*} _type
* @param {*} _client
*/
app.LOG = (_message, _action, _type, _client) => {
return new Promise((resolve) => {
if (!_type) {
_type = "info";
}
if (!_action) {
_action = "";
}
if (!_client) {
_client = "";
}
if (process.env.NODE_ENV === "development" || process.env.VERBOSE) {
console.log(chalk.red("-----------------------------------------------------------------------------"));
console.log(chalk.green("TYPE: "), _type);
console.log(chalk.blue("ACTION: "), _action);
console.log(_message);
if (_client) {
console.log(chalk.yellow("CLIENT: "), _client);
}
console.log();
console.log(chalk.red("============================================================================="));
console.log();
}
app.models.system_log.create({
message: _message,
type: _type,
action: _action,
client: _client
});
resolve();
});
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment