Skip to content

Commit 5854cea

Browse files
rcourtmanclaude
andcommitted
clean: remove debug logging from configuration API
- Clean up all debug console.log statements from settings system - Maintain error logging for troubleshooting production issues - Keep essential reload functionality for additional endpoints - Finalize comprehensive settings system implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4976295 commit 5854cea

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

server/configApi.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@ class ConfigApi {
6464
*/
6565
async saveConfig(config) {
6666
try {
67-
console.log('[ConfigApi.saveConfig] Called with:', JSON.stringify(config, null, 2));
68-
console.log('[ConfigApi.saveConfig] .env path:', this.envPath);
69-
7067
// Read existing .env file to preserve other settings
7168
const existingConfig = await this.readEnvFile();
72-
console.log('[ConfigApi.saveConfig] Existing config keys:', Object.keys(existingConfig));
7369

7470
// Handle both old structured format and new raw .env variable format
7571
if (config.proxmox || config.pbs || config.advanced) {
@@ -81,14 +77,10 @@ class ConfigApi {
8177
}
8278

8379
// Write back to .env file
84-
console.log('[ConfigApi.saveConfig] Writing config with keys:', Object.keys(existingConfig));
8580
await this.writeEnvFile(existingConfig);
86-
console.log('[ConfigApi.saveConfig] .env file written successfully');
8781

8882
// Reload configuration in the application
89-
console.log('[ConfigApi.saveConfig] Reloading configuration...');
9083
await this.reloadConfiguration();
91-
console.log('[ConfigApi.saveConfig] Configuration reloaded successfully');
9284

9385
return { success: true };
9486
} catch (error) {
@@ -103,7 +95,6 @@ class ConfigApi {
10395
handleStructuredConfig(config, existingConfig) {
10496
// Update with new values
10597
if (config.proxmox) {
106-
console.log('[ConfigApi.saveConfig] Updating Proxmox config');
10798
existingConfig.PROXMOX_HOST = config.proxmox.host;
10899
existingConfig.PROXMOX_PORT = config.proxmox.port || '8006';
109100
existingConfig.PROXMOX_TOKEN_ID = config.proxmox.tokenId;
@@ -115,8 +106,6 @@ class ConfigApi {
115106

116107
// Always allow self-signed certificates by default for Proxmox
117108
existingConfig.PROXMOX_ALLOW_SELF_SIGNED_CERT = 'true';
118-
} else {
119-
console.log('[ConfigApi.saveConfig] No Proxmox config provided');
120109
}
121110

122111
if (config.pbs) {
@@ -173,12 +162,9 @@ class ConfigApi {
173162
* Handle raw .env variable format (new settings form)
174163
*/
175164
handleRawEnvConfig(config, existingConfig) {
176-
console.log('[ConfigApi.saveConfig] Processing raw .env variable format');
177-
178165
// Directly update existing config with new values
179166
Object.entries(config).forEach(([key, value]) => {
180167
if (value !== undefined && value !== '') {
181-
console.log(`[ConfigApi.saveConfig] Setting ${key} = ${value}`);
182168
existingConfig[key] = value;
183169
}
184170
});
@@ -207,7 +193,6 @@ class ConfigApi {
207193
*/
208194
async testConfig(config) {
209195
try {
210-
console.log('[ConfigApi.testConfig] Testing config:', JSON.stringify(config, null, 2));
211196

212197
// Handle both old structured format and new raw .env format
213198
let proxmoxHost, proxmoxPort, proxmoxTokenId, proxmoxTokenSecret;
@@ -312,7 +297,6 @@ class ConfigApi {
312297
await testClient.client.get('/nodes');
313298
}
314299

315-
console.log('[ConfigApi.testConfig] Connection test successful');
316300
return { success: true };
317301
} catch (error) {
318302
console.error('Configuration test failed:', error);
@@ -412,7 +396,6 @@ class ConfigApi {
412396

413397
try {
414398
await fs.writeFile(this.envPath, lines.join('\n'), 'utf8');
415-
console.log(`[ConfigApi.writeEnvFile] Successfully wrote ${lines.length} lines to ${this.envPath}`);
416399
} catch (writeError) {
417400
console.error('[ConfigApi.writeEnvFile] Error writing file:', writeError);
418401
throw writeError;
@@ -437,16 +420,8 @@ class ConfigApi {
437420
// Reload environment variables
438421
require('dotenv').config();
439422

440-
// Log environment variables for debugging
441-
const envVars = Object.keys(process.env).filter(key =>
442-
key.startsWith('PROXMOX_') || key.startsWith('PBS_')
443-
).sort();
444-
console.log('[ConfigApi.reloadConfiguration] Environment variables after reload:', envVars);
445-
446423
// Reload configuration
447424
const { endpoints, pbsConfigs, isConfigPlaceholder } = loadConfiguration();
448-
console.log(`[ConfigApi.reloadConfiguration] Loaded ${endpoints.length} Proxmox endpoints:`, endpoints.map(e => ({ id: e.id, name: e.name, host: e.host })));
449-
console.log(`[ConfigApi.reloadConfiguration] Loaded ${pbsConfigs.length} PBS configs:`, pbsConfigs.map(p => ({ id: p.id, name: p.name, host: p.host })));
450425

451426
// Get state manager instance
452427
const stateManager = require('./state');
@@ -456,10 +431,7 @@ class ConfigApi {
456431
stateManager.setEndpointConfigurations(endpoints, pbsConfigs);
457432

458433
// Reinitialize API clients
459-
console.log('[ConfigApi.reloadConfiguration] Reinitializing API clients...');
460434
const { apiClients, pbsApiClients } = await initializeApiClients(endpoints, pbsConfigs);
461-
console.log(`[ConfigApi.reloadConfiguration] Initialized ${Object.keys(apiClients).length} API clients:`, Object.keys(apiClients));
462-
console.log(`[ConfigApi.reloadConfiguration] Initialized ${Object.keys(pbsApiClients).length} PBS clients:`, Object.keys(pbsApiClients));
463435

464436
// Update global references
465437
if (global.pulseApiClients) {
@@ -477,16 +449,6 @@ class ConfigApi {
477449
global.lastReloadTime = Date.now();
478450
}
479451

480-
// Manually verify additional endpoints are loaded
481-
let additionalEndpointsFound = 0;
482-
let i = 2;
483-
while (process.env[`PROXMOX_HOST_${i}`]) {
484-
console.log(`[ConfigApi.reloadConfiguration] Found additional endpoint ${i}: PROXMOX_HOST_${i}=${process.env[`PROXMOX_HOST_${i}`]}`);
485-
additionalEndpointsFound++;
486-
i++;
487-
}
488-
console.log(`[ConfigApi.reloadConfiguration] Total additional endpoints found in environment: ${additionalEndpointsFound}`);
489-
490452
// Trigger a discovery cycle if we have endpoints configured
491453
if (endpoints.length > 0) {
492454
console.log('Triggering discovery cycle after configuration reload...');
@@ -523,9 +485,7 @@ class ConfigApi {
523485
// Save configuration
524486
app.post('/api/config', async (req, res) => {
525487
try {
526-
console.log('[API /api/config] POST received with body:', JSON.stringify(req.body, null, 2));
527488
const result = await this.saveConfig(req.body);
528-
console.log('[API /api/config] Save result:', result);
529489
res.json({ success: true });
530490
} catch (error) {
531491
console.error('[API /api/config] Error:', error);

0 commit comments

Comments
 (0)