updated loggers to getLogger
This commit is contained in:
parent
1ccdbddb71
commit
2aaeba2f6c
16 changed files with 72 additions and 97 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { Pool, PoolClient, QueryResult as PgQueryResult, QueryResultRow } from 'pg';
|
||||
import { postgresConfig } from '@stock-bot/config';
|
||||
import { Logger } from '@stock-bot/logger';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type {
|
||||
PostgreSQLClientConfig,
|
||||
PostgreSQLConnectionOptions,
|
||||
|
|
@ -21,7 +21,7 @@ export class PostgreSQLClient {
|
|||
private pool: Pool | null = null;
|
||||
private readonly config: PostgreSQLClientConfig;
|
||||
private readonly options: PostgreSQLConnectionOptions;
|
||||
private readonly logger: Logger;
|
||||
private readonly logger: ReturnType<typeof getLogger>;
|
||||
private readonly healthMonitor: PostgreSQLHealthMonitor;
|
||||
private readonly transactionManager: PostgreSQLTransactionManager;
|
||||
private isConnected = false;
|
||||
|
|
@ -38,7 +38,7 @@ export class PostgreSQLClient {
|
|||
...options
|
||||
};
|
||||
|
||||
this.logger = new Logger('PostgreSQLClient');
|
||||
this.logger = getLogger('postgres-client');
|
||||
this.healthMonitor = new PostgreSQLHealthMonitor(this);
|
||||
this.transactionManager = new PostgreSQLTransactionManager(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Logger } from '@stock-bot/logger';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { PostgreSQLClient } from './client';
|
||||
import type { PostgreSQLHealthCheck, PostgreSQLHealthStatus, PostgreSQLMetrics } from './types';
|
||||
|
||||
|
|
@ -9,14 +9,14 @@ import type { PostgreSQLHealthCheck, PostgreSQLHealthStatus, PostgreSQLMetrics }
|
|||
*/
|
||||
export class PostgreSQLHealthMonitor {
|
||||
private readonly client: PostgreSQLClient;
|
||||
private readonly logger: Logger;
|
||||
private readonly logger: ReturnType<typeof getLogger>;
|
||||
private healthCheckInterval: NodeJS.Timeout | null = null;
|
||||
private metrics: PostgreSQLMetrics;
|
||||
private lastHealthCheck: PostgreSQLHealthCheck | null = null;
|
||||
|
||||
constructor(client: PostgreSQLClient) {
|
||||
this.client = client;
|
||||
this.logger = new Logger('PostgreSQLHealthMonitor');
|
||||
this.logger = getLogger('postgres-health-monitor');
|
||||
this.metrics = {
|
||||
queriesPerSecond: 0,
|
||||
averageQueryTime: 0,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { PoolClient } from 'pg';
|
||||
import { Logger } from '@stock-bot/logger';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { PostgreSQLClient } from './client';
|
||||
import type { TransactionCallback } from './types';
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ import type { TransactionCallback } from './types';
|
|||
*/
|
||||
export class PostgreSQLTransactionManager {
|
||||
private readonly client: PostgreSQLClient;
|
||||
private readonly logger: Logger;
|
||||
private readonly logger: ReturnType<typeof getLogger>;
|
||||
|
||||
constructor(client: PostgreSQLClient) {
|
||||
this.client = client;
|
||||
this.logger = new Logger('PostgreSQLTransactionManager');
|
||||
this.logger = getLogger('postgres-transaction-manager');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue