jams_logger
Version:
A RPG Maker MZ plugin creates a log in both console and logger.txt
28 lines (24 loc) • 794 B
JavaScript
/*:
* @plugindesc Output information to console and log file.
* @author Michael Stephens
*/
function JamsLogger() {
this.initialize(...arguments);
}
JamsLogger.prototype.initialize = function () {
this.fs = require('fs');
this.file = 'logger.txt';
this.fs.appendFileSync(this.file, "DateTime|Description|Details\n");
};
JamsLogger.prototype.log = function (...args) {
var s = ""
for (i in args) {
s = s + JSON.stringify(args[i]);
}
this.fs.appendFileSync(this.file, new Date().toUTCString() + "|" + JSON.stringify(args[0])+"|"+s+"\n");
console.log(new Date().toUTCString(),args[0],args);
};
var Imported = Imported || {};
Imported.Jams = "1.0.0";
var Jams = Jams || {};
Jams.Logger = Jams.Logger || new JamsLogger();