First setup of logging implemented.

#FA-8 #FA-10
This commit is contained in:
admin
2023-01-14 09:38:17 -08:00
parent 899dce3143
commit be5c79f086
27 changed files with 1265 additions and 2 deletions

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_script_include">
<sys_script_include action="INSERT_OR_UPDATE">
<access>package_private</access>
<active>true</active>
<api_name>x_355681_fa.ProcessorUtils</api_name>
<caller_access/>
<client_callable>false</client_callable>
<description/>
<name>ProcessorUtils</name>
<script><![CDATA[var _source;
var ProcessorUtils = Class.create();
ProcessorUtils.prototype = {
initialize: function(options) {
var { table, scope, name } = options;
if(table) this.setSource(options.table, {scope, name});
},
setSource: function(table, options){
var { scope, name } = options;
var sourceGr = new GlideRecord(table);
sourceGr.addQuery("name", name);
sourceGr.addQuery("sys_scope.scope", scope);
sourceGr.query();
if(sourceGr.next()){
_source = sourceGr;
}
},
wrapper: function(scopedClass){
Object.getOwnPropertyNames(scopedClass).forEach(function(f) {
if(Object.getOwnPropertyDescriptor(scopedClass,f).writable){
if (typeof scopedClass[f] === 'function') {
var old = scopedClass[f];
var funcName = f.toString();
if(_source){
var sourceTable = _source.getTableName();
var sourceID = _source.getValue("sys_id");
}
scopedClass[f] = function() {
var returnValue = false;
try{
if(old == undefined) throw new Error("Function: " + funcName + " does not exist");
returnValue = old.apply(this, arguments);
}catch(err){
var func = funcName ? "Function: " + funcName : undefined;
var message = err.message ? "Message: " +err.message : undefined;
var line = err.lineNumber ? "Line: " + err.lineNumber : undefined;
var options = {
type: "error",
funcName: funcName
};
new LogUtils().write("message", options);
}
return returnValue;
};
}
}
});
},
type: 'ProcessorUtils'
};]]></script>
<sys_class_name>sys_script_include</sys_class_name>
<sys_created_by>admin</sys_created_by>
<sys_created_on>2023-01-13 22:06:41</sys_created_on>
<sys_id>57d21676975821105838bfb3f153af24</sys_id>
<sys_name>ProcessorUtils</sys_name>
<sys_package display_value="Fulfilment Automater" source="x_355681_fa">c04afa629713111093a8337e6253af6d</sys_package>
<sys_policy>read</sys_policy>
<sys_scope display_value="Fulfilment Automater">c04afa629713111093a8337e6253af6d</sys_scope>
<sys_update_name>sys_script_include_57d21676975821105838bfb3f153af24</sys_update_name>
</sys_script_include>
</record_update>