Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var DeveloperDebugUtility = Class.create();
DeveloperDebugUtility.prototype = {
initialize: function() {},

// Checks if debug logging is enabled via system property

_enable_debug: function() {
// System Property: enable_debug_for_scripts (true/false)
return gs.getProperty('enable_debug_for_scripts') == 'true';
},

// Controlled debug logger
// {String} message - The message to log
_debug: function(message) {
if (this._enable_debug()) {
gs.info('[DEBUG LOG] ' + message);
}
},

// Example function where controlled debugging can be used
addFunction: function(data) {
try {
// Example logic: simulate some operation
this._debug('Executing addFunction with data: ' + JSON.stringify(data));

// core logic here

this._debug('addFunction executed successfully.');
} catch (e) {
this._debug('Error executing addFunction:\n' + e);
}
},

type: 'DeveloperDebugUtility'
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Developer Debug Utility (Controlled Logging)
Create a systemProperty - enable_debug_for_scripts (Boolean value)

# Overview
This utility provides a centralized, configurable debug logging mechanism for developers.
Instead of using gs.info(), gs.log(), or gs.warn() - which create permanent logs in the system, developers can now log messages conditionally through a system property.

When the property 'enable_debug_for_scripts' is set to 'true', debug messages are logged; otherwise, all debug calls are ignored.
This makes it ideal for debugging issues in Production without modifying code or flooding system logs.


# Objective
To provide a reusable, lightweight debugging utility that allows developers to:
- Enable/disable debug logs globally via a system property.
- Avoid unnecessary system log entries when debugging is not needed.
- Maintain clean, controlled, and consistent debug output across server-side scripts.
Loading