Script Include Logging

tenagra
Kilo Expert

Can anyone help me understand why the gs.log function isn't working in my script include below?   I am running Jakarta.  

var CIAutoCategorization = Class.create();

CIAutoCategorization.prototype = {

      initialize: function() {},

// Get Categorization items by going through the parent/child relationships in the [CI Relations] table.

getInfoByRelationship : function (sysid, checkParent, table, debug, logSource)

{

var info = {   /* this variable is used in all functions below for consistency. */

location:'test',

application:'test1',

businessUnit:'testme',

environment:'test123',

supportGroup:null

};

gs.log('@@@Test');

var msg = 'SI:CIAutoCategorization.getInfoByRelationship() :   Vars : sysId=['+sysid+'] | checkParent=['+checkParent +'] | table=['+table+'] | debug=['+debug+'] | logSource['+logSource+']';

gs.log('@@@ ' + msg);

return info;

}

The getInfoByRelationship is being called from a Discovery Business Rule on insert/update.   The actual call looks like this:

categoryInfo= new CIAutoCategorization();

info = categoryInfo.getInfoByRelationship(sysid, checkParent, tableName, debug, logSource);

gs.log(JSON.stringify(info, null, 4));

The JSON.stringify does return the info variable correctly.   So I know that the function is being called.   However, the gs.log messages within the function are not writing to the log file.  

What am I missing here?

Nathan

1 ACCEPTED SOLUTION

purbalipc
Tera Expert

Ensure that your application / API scope is global?


View solution in original post

4 REPLIES 4

purbalipc
Tera Expert

Ensure that your application / API scope is global?


changed to global and it worked.   was scoped to application.



Thank you.



Nathan


Uncle Rob
Kilo Patron

gs.log doesn't work in scoped apps, and very little will warn you about this, so that's the first thing I'd check.


If you're in a scoped app, you'll want to learn about the GlideSystem API for logging.



SIDE NOTE


Looks like you're trying to make your log statements stand out by placing easily searchable unique test.   There's a WAY easier way to do that.
gs.log(parm1,parm2).   Parm1 is what you want to log.   Parm2 is a string that will be the "Source" in the log table.


Thank you for the assistance.



Regarding your side note.   Yes, normally I use the parm2 for source.   Was removing possible reasons it was failing and bringing things to the bare minimum to help troubleshoot.



Nathan