// Centralized Logger for Production
// Use environment variable or --debug flag to control debug output

const DEBUG_MODE = process.argv.includes('--debug') || 
                   process.env.DEBUG === 'true' || 
                   process.env.NODE_ENV === 'development';

class Logger {
  constructor(module) {
    this.module = module;
  }

  debug(...args) {
    if (DEBUG_MODE) {
      console.log(`[DEBUG][${this.module}]`, ...args);
    }
  }

  info(...args) {
    console.log(`[INFO][${this.module}]`, ...args);
  }

  warn(...args) {
    console.warn(`[WARN][${this.module}]`, ...args);
  }

  error(...args) {
    console.error(`[ERROR][${this.module}]`, ...args);
  }

  // Keep critical startup/connection messages
  startup(...args) {
    console.log(`✅ [${this.module}]`, ...args);
  }
  
  // Show execution results (always visible)
  result(...args) {
    console.log(`📝 [${this.module}]`, ...args);
  }
}

// Show debug mode status on startup
if (DEBUG_MODE) {
  console.log('🔧 DEBUG MODE ENABLED - Use devicely without --debug flag for quiet mode\n');
}

module.exports = Logger;
