Skip to content

Commit 2144c64

Browse files
Create DeveloperDebugUtility.js
1 parent 0af7289 commit 2144c64

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var DeveloperDebugUtility = Class.create();
2+
DeveloperDebugUtility.prototype = {
3+
initialize: function() {},
4+
5+
// Checks if debug logging is enabled via system property
6+
7+
_enable_debug: function() {
8+
// System Property: enable_debug_for_scripts (true/false)
9+
return gs.getProperty('enable_debug_for_scripts') == 'true';
10+
},
11+
12+
// Controlled debug logger
13+
// {String} message - The message to log
14+
_debug: function(message) {
15+
if (this._enable_debug()) {
16+
gs.info('[DEBUG LOG] ' + message);
17+
}
18+
},
19+
20+
// Example function where controlled debugging can be used
21+
addFunction: function(data) {
22+
try {
23+
// Example logic: simulate some operation
24+
this._debug('Executing addFunction with data: ' + JSON.stringify(data));
25+
26+
// core logic here
27+
28+
this._debug('addFunction executed successfully.');
29+
} catch (e) {
30+
this._debug('Error executing addFunction:\n' + e);
31+
}
32+
},
33+
34+
type: 'DeveloperDebugUtility'
35+
};

0 commit comments

Comments
 (0)