Implement centralized logging with RMABLogger

Replaces scattered console statements with a unified RMABLogger across backend API routes and services. Adds LOG_LEVEL-based filtering, job-aware database persistence, and context-based logging. Updates documentation to describe the new logging system and usage patterns. Also documents qBittorrent CSRF header fix
This commit is contained in:
kikootwo
2026-01-12 12:45:48 -05:00
parent ba5f5cf7d6
commit 682836237b
118 changed files with 1623 additions and 1079 deletions
+11 -9
View File
@@ -3,6 +3,10 @@
* Documentation: documentation/backend/services/environment.md
*/
import { RMABLogger } from './logger';
const logger = RMABLogger.create('URL');
/**
* Get application base URL for OAuth callbacks and redirects
*
@@ -35,22 +39,20 @@ export function getBaseUrl(): string {
// Validate URL format
if (!url.startsWith('http://') && !url.startsWith('https://')) {
console.warn(`[URL Utility] Invalid base URL format: ${url}. URLs must start with http:// or https://`);
logger.warn(`Invalid base URL format: ${url}. URLs must start with http:// or https://`);
}
// Production warning if using localhost
if (process.env.NODE_ENV === 'production' && url.includes('localhost')) {
console.warn('[URL Utility] ⚠️ WARNING: Using localhost URL in production. OAuth callbacks may fail. Set PUBLIC_URL environment variable.');
logger.warn('Using localhost URL in production. OAuth callbacks may fail. Set PUBLIC_URL environment variable.');
}
// Log which variable is being used (debug only)
if (process.env.LOG_LEVEL === 'debug') {
const source = publicUrl ? 'PUBLIC_URL' :
nextAuthUrl ? 'NEXTAUTH_URL' :
baseUrl ? 'BASE_URL' :
'default (localhost)';
console.debug(`[URL Utility] Using base URL from ${source}: ${url}`);
}
const source = publicUrl ? 'PUBLIC_URL' :
nextAuthUrl ? 'NEXTAUTH_URL' :
baseUrl ? 'BASE_URL' :
'default (localhost)';
logger.debug(`Using base URL from ${source}: ${url}`);
return url;
}