- Implemented debug information

- Started table for Fulfillment Plan
This commit is contained in:
admin
2023-01-28 05:12:55 -08:00
parent 8fc009ca77
commit 031d949a83
37 changed files with 2103 additions and 84 deletions

View File

@ -9,6 +9,8 @@
<name>LogUtils</name>
<script><![CDATA[var LogUtils = Class.create();
LogUtils.prototype = {
source: {},
initialize: function() {
},
@ -25,14 +27,64 @@ LogUtils.prototype = {
}
},
write: function(message, options = {}){
debug: function(message, name, options = {}){
if(message){
var logGr = this._createLogTemplate(message, "debug", {function_name: name, ...this.source});
if(logGr){
logGr.insert();
}
}
},
error: function(message, name, options = {}){
if(message){
var logGr = this._createLogTemplate(message, "error", {function_name: name, ...this.source});
if(logGr){
logGr.insert();
}
}
},
info: function(message, name, options = {}){
if(message){
var logGr = this._createLogTemplate(message, "info", {function_name: name, ...this.source});
if(logGr){
logGr.insert();
}
}
},
_createLogTemplate: function(message, type, values = {}){
// if(this._callee && this._callee.length > 0 && (type == "error" || type == "debug")){
// var reversedCallee = JSON.parse(JSON.stringify(this._callee)).reverse();
// message += "\n\nFunction trace: " + reversedCallee.join(" < ");
// }
var logGr = new GlideRecord('x_355681_fa_log');
logGr.initialize();
logGr.setValue("type", type);
logGr.setValue("timestamp", (new Date()).toISOString());
logGr.setValue("message", message);
logGr.setValue("impacted_record", current.sys_id);
if(this._callee){
logGr.setValue("debug_information", JSON.stringify(this._callee,undefined,2));
}
for(var key in values){
logGr.setValue(key, values[key]);
}
return logGr;
},
write_dep: function(message, options = {}){
var {
type = "info",
timestamp = new Date(),
funcName = "",
currentRecord = current
details = {}
} = options;
if(this.details){
gs.info("scope: " + JSON.stringify(this.details))
}
if(message){
var logGr = new GlideRecord('x_355681_fa_log');
logGr.initialize();
@ -40,11 +92,18 @@ LogUtils.prototype = {
logGr.setValue("timestamp", timestamp.toISOString());
logGr.setValue("message", message);
logGr.setValue("function_name", funcName);
if(currentRecord)
logGr.setValue("impacted_record", currentRecord.sys_id);
if(this.logSource){
logGr.setValue("source_table", this.logSource.table);
logGr.setValue("source_record", this.logSource.sys_id);
if(current)
logGr.setValue("impacted_record", current.sys_id);
if(details){
logGr.setValue("source_table", details.table);
if(details.sys_id){
logGr.setValue("source_record", details.sys_id);
}else{
var sourceRec = new HelperUtils().getRecFromAttributes(details);
if(sourceRec){
logGr.setValue("source_record", sourceRec.getValue('sys_id'));
}
}
}
logGr.insert();
}