fixed up logger error to make it better to handle in code

This commit is contained in:
Bojan Kucera 2025-06-07 11:58:24 -04:00
parent db66687f48
commit d0bb4db042
18 changed files with 51 additions and 45 deletions

View file

@ -44,13 +44,13 @@ export class QuestDBHealthMonitor {
try {
await this.performHealthCheck();
} catch (error) {
this.logger.error('Health check failed', { error });
this.logger.error('Health check failed', error);
}
}, intervalMs);
// Perform initial health check
this.performHealthCheck().catch(error => {
this.logger.error('Initial health check failed', { error });
this.logger.error('Initial health check failed', error);
});
}

View file

@ -362,7 +362,7 @@ export class QuestDBInfluxWriter {
if (attempt <= options.retryAttempts) {
await this.sleep(options.retryDelay * attempt); // Exponential backoff
} else {
throw new Error(`Failed to write to QuestDB after ${options.retryAttempts} attempts: ${error}`);
throw new Error(`Failed to write to QuestDB after ${options.retryAttempts} attempts: $error`);
}
}
}
@ -380,7 +380,7 @@ export class QuestDBInfluxWriter {
try {
await this.flush(options);
} catch (error) {
this.logger.error('Scheduled flush failed', { error });
this.logger.error('Scheduled flush failed', error);
}
}, options.flushInterval);
}

View file

@ -166,7 +166,7 @@ export class QuestDBSchemaManager {
await this.createTable(schema);
this.logger.info(`Table ${tableName} created successfully`);
} catch (error) {
this.logger.error(`Failed to create table ${tableName}`, { error });
this.logger.error(`Failed to create table ${tableName}`, error);
throw error;
}
}
@ -201,7 +201,7 @@ export class QuestDBSchemaManager {
await this.client.query(sql);
this.logger.info(`Table ${tableName} dropped`);
} catch (error) {
this.logger.error(`Failed to drop table ${tableName}`, { error });
this.logger.error(`Failed to drop table ${tableName}`, error);
throw error;
}
}
@ -219,7 +219,7 @@ export class QuestDBSchemaManager {
return result.rows.length > 0 && result.rows[0].count > 0;
} catch (error) {
this.logger.error(`Error checking if table exists: ${tableName}`, { error });
this.logger.error(`Error checking if table exists: ${tableName}`, error);
return false;
}
}
@ -260,7 +260,7 @@ export class QuestDBSchemaManager {
const stats = await this.getTableStats(tableName);
this.logger.info(`Table ${tableName} stats`, stats);
} catch (error) {
this.logger.error(`Failed to optimize table ${tableName}`, { error });
this.logger.error(`Failed to optimize table ${tableName}`, error);
throw error;
}
}
@ -280,7 +280,7 @@ export class QuestDBSchemaManager {
return result.rows[0] || {};
} catch (error) {
this.logger.error(`Failed to get table stats for ${tableName}`, { error });
this.logger.error(`Failed to get table stats for ${tableName}`, error);
throw error;
}
}
@ -293,7 +293,7 @@ export class QuestDBSchemaManager {
await this.client.query(`TRUNCATE TABLE ${tableName}`);
this.logger.info(`Table ${tableName} truncated`);
} catch (error) {
this.logger.error(`Failed to truncate table ${tableName}`, { error });
this.logger.error(`Failed to truncate table ${tableName}`, error);
throw error;
}
}