Skip to content

Commit 49da63c

Browse files
Create debugLogger.md, feat(snippets/glide-helpers): add environment-aware logger, paginated query, and PR note template
Environment-aware logging for server/client scripts, preventing production log clutter while easing debugging in sub-prod instances.
1 parent 675e853 commit 49da63c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
```markdown
2+
# debugLogger
3+
4+
> A simple environment-aware logging utility for client and server scripts.
5+
6+
**Use case:**
7+
In one of my projects, we wanted to log messages only in non-production environments without commenting them out each time. This small helper does that elegantly.
8+
9+
```javascript
10+
/**
11+
* debugLogger(message, level)
12+
* Logs only if NOT in production.
13+
* Level can be 'info', 'warn', or 'error'
14+
*/
15+
var debugLogger = (function() {
16+
var isProd = gs.getProperty('instance_name') === 'prod-instance'; // change per your instance
17+
return function(msg, level) {
18+
if (isProd) return;
19+
level = level || 'info';
20+
gs[level]('[DEBUG] ' + msg);
21+
};
22+
})();
23+
24+
// Example usage:
25+
debugLogger('Checking record count...', 'info');

0 commit comments

Comments
 (0)