- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 06:04 AM
I often see code like this
var debug = true;
if (debug) gs.print(msg);
if (debug) gs.info(msg);
Is there a specific reason why people don't use the GlideSystem instead? Like this
if (gs.isDebugging()) gs.print(msg);
Or maybe even shorter
gs.debug(msg);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 06:12 AM
FWIW, I often have distinct debugging in each of my script includes so I can debug them independent of each other (not get overwhelmed with debug output.) In those cases, I'll make an _debug function.
_debug : function(msg) {
if (this.debug)
gs.debug(msg);
}
Then call it in various places as
this._debug(recordCount + ' records read');
I can then turn on and off the debug property in the script include with a property so I don't have to modify code in production to enable/disable debugging.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 06:28 AM
Wow, I really need to stop getting up at 3AM and start getting more sleep. Thanks.
I'll argue that the "or" in that is somewhat independent of each other. I could have session debugging off, but the logging.verbosity set to debug and get no output. Does that mean isDebugging returns true? I could also have session debugging on and logging.verbosity set to none and receive no output. Does that return true? Inquiring minds want to know... I need to some quick testing to find out more.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 06:38 AM
This answer is... OR. If session debugging is on OR the scoped property is debug, then the function returns true. I'm not sure I see a value in it to be honest. Still consider the impact to the best practices (even though I don't own them any more.)
This was certainly educational... all before 7AM.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 06:18 AM
As for linking to the wiki instead of docs... Jive has an issue with deep linking (as evidence of your link to gs.isDebugging() taking me to the developer home page instead of the actual page.)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 06:21 AM
Inquiry made to our developer portal people about more info on gs.isDebugging().

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2016 06:12 AM
FWIW, I often have distinct debugging in each of my script includes so I can debug them independent of each other (not get overwhelmed with debug output.) In those cases, I'll make an _debug function.
_debug : function(msg) {
if (this.debug)
gs.debug(msg);
}
Then call it in various places as
this._debug(recordCount + ' records read');
I can then turn on and off the debug property in the script include with a property so I don't have to modify code in production to enable/disable debugging.