Skip to content
Back to skills

971 Debug Logging Toggle Feature 2fa4236e

ASecurity

**Version Implemented:** 0.229.001

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 11, 2026
developmentpythontestingdebuggingfrontendbackendperformance

Works with

  • cli

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 971-debug_logging_toggle_feature_2fa4236e --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 971 Debug Logging Toggle Feature 2fa4236e?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 971 Debug Logging Toggle Feature 2fa4236e
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-971-debug-logging-toggle-feature-2fa4236e/badge)](https://www.skillsdirectory.com/skills/tools-only-971-debug-logging-toggle-feature-2fa4236e)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# DEBUG LOGGING TOGGLE FEATURE

**Version Implemented:** 0.229.001

## Overview
A new feature that allows administrators to enable or disable debug print statements across the entire SimpleChat application through the admin settings interface.

**Fixed/Implemented in version: 0.228.015**

## Problem Solved
Previously, debug print statements using `debug_print(f"...")` were hardcoded throughout the application and could not be turned on or off without code changes. This made it difficult to:
- Control debug output in production environments
- Enable debugging only when needed for troubleshooting
- Reduce console noise during normal operation
- Provide a clean way to manage development vs. production logging

## Solution
Implemented a centralized debug logging toggle that:
- Adds a setting `enable_debug_logging` to the admin settings
- Provides a UI toggle in the admin settings Logging tab
- Creates helper functions to conditionally print debug messages
- Allows real-time control of debug output without code changes

## Technical Implementation

### 1. Settings Integration
- Added `enable_debug_logging: False` to default settings in `functions_settings.py`
- Added form handling in `route_frontend_admin_settings.py`
- Added UI toggle in `admin_settings.html` Logging tab

### 2. Debug Helper Functions
Created `functions_debug.py` with two main functions:

```python
def debug_print(message):
    """Print debug message only if debug logging is enabled"""
    
def is_debug_enabled():
    """Check if debug logging is enabled"""
```

### 3. Admin UI
Added a new toggle in the admin settings Logging tab:
- Toggle switch to enable/disable debug logging
- Info tooltip explaining the feature
- Blue info alert explaining usage
- Positioned alongside Application Insights logging

### 4. Usage Pattern
Replace existing debug prints:
```python
# Before:
debug_print(f"Some debug message")

# After:
from functions_debug import debug_print
debug_print("Some debug message")
```

## Files Modified

### Core Implementation
- `functions_settings.py` - Added default setting
- `functions_debug.py` - New debug helper functions
- `route_frontend_admin_settings.py` - Form handling
- `admin_settings.html` - UI toggle
- `config.py` - Updated version

### Example Usage
- `route_backend_chats.py` - Updated several debug prints to use new system

### Testing
- `test_debug_logging_toggle.py` - Comprehensive functional test

## Usage Instructions

### For Administrators
1. Navigate to Admin Settings
2. Click on the "Logging" tab
3. Toggle "Enable Debug Logging" on/off as needed
4. Changes take effect immediately

### For Developers
1. Import the debug function: `from functions_debug import debug_print`
2. Replace `debug_print(f"message")` with `debug_print("message")`
3. Use `is_debug_enabled()` for conditional debug blocks

## Benefits
- **Performance**: No debug output overhead when disabled
- **Clean Logs**: Reduces console noise in production
- **Flexibility**: Enable debugging only when troubleshooting
- **Centralized Control**: Single setting controls all debug output
- **Backward Compatible**: Existing debug prints still work
- **Safe**: Error handling prevents crashes if settings unavailable

## Testing Coverage
- Debug function behavior when enabled/disabled
- Settings integration and default values
- Error handling for configuration issues
- UI toggle functionality
- Real-time control verification

## Migration Path
Existing `debug_print(f"...")` statements can be:
1. Left as-is (they will still work)
2. Gradually migrated to use `debug_print()` 
3. Updated during future code maintenance

This provides a smooth transition path while immediately offering the toggle functionality for any new debug statements.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.