Fix jwt-token
This commit is contained in:
@@ -3,8 +3,26 @@ const path = require('path');
|
||||
|
||||
class ApiDebugLogger {
|
||||
constructor() {
|
||||
this.logFile = path.join(__dirname, '..', 'api_debug.log');
|
||||
this.logFile = path.join(__dirname, '..', '..', 'api_debug.log');
|
||||
this.enabled = process.env.NODE_ENV === 'development' || process.env.API_DEBUG === 'true';
|
||||
|
||||
// Debug logging setup
|
||||
if (this.enabled) {
|
||||
console.log(`🐛 ApiDebugLogger: Enabled (NODE_ENV=${process.env.NODE_ENV}, API_DEBUG=${process.env.API_DEBUG})`);
|
||||
console.log(`🐛 ApiDebugLogger: Log file path: ${this.logFile}`);
|
||||
|
||||
// Ensure the log file exists
|
||||
try {
|
||||
if (!fs.existsSync(this.logFile)) {
|
||||
fs.writeFileSync(this.logFile, `# API Debug Log Started at ${new Date().toISOString()}\n`);
|
||||
console.log(`🐛 ApiDebugLogger: Created log file at ${this.logFile}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ ApiDebugLogger: Failed to create log file: ${error}`);
|
||||
}
|
||||
} else {
|
||||
console.log(`🐛 ApiDebugLogger: Disabled (NODE_ENV=${process.env.NODE_ENV}, API_DEBUG=${process.env.API_DEBUG})`);
|
||||
}
|
||||
}
|
||||
|
||||
log(method, url, statusCode, requestBody = {}, responseBody = {}, headers = {}) {
|
||||
@@ -31,8 +49,9 @@ class ApiDebugLogger {
|
||||
|
||||
try {
|
||||
fs.appendFileSync(this.logFile, logEntry + '\n');
|
||||
console.log(`🐛 API Log: ${method.toUpperCase()} ${url} - ${statusCode}`);
|
||||
} catch (error) {
|
||||
console.error('Failed to write to API debug log:', error);
|
||||
console.error('❌ Failed to write to API debug log:', error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +97,9 @@ class ApiDebugLogger {
|
||||
|
||||
try {
|
||||
fs.appendFileSync(this.logFile, logEntry + '\n');
|
||||
console.log(`🐛 API Request: ${req.method} ${req.url}`);
|
||||
} catch (error) {
|
||||
console.error('Failed to write request to API debug log:', error);
|
||||
console.error('❌ Failed to write request to API debug log:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user