micro-generate 1.3.6 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -95,7 +95,7 @@ export function getEnv(name: string): string {
|
|
|
95
95
|
// 5. src/database/redis.ts
|
|
96
96
|
if (useRedis) {
|
|
97
97
|
const redisContent = `import { Redis, RedisOptions } from 'ioredis';
|
|
98
|
-
|
|
98
|
+
import { logger } from 'micro-generate';
|
|
99
99
|
|
|
100
100
|
export class RedisConnector {
|
|
101
101
|
private defaultClient: Redis | null = null;
|
|
@@ -123,7 +123,7 @@ export class RedisConnector {
|
|
|
123
123
|
|
|
124
124
|
async connect(): Promise<void> {
|
|
125
125
|
if (this.defaultClient) {
|
|
126
|
-
|
|
126
|
+
logger.info('Redis default client already connected');
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
try {
|
|
@@ -131,7 +131,7 @@ export class RedisConnector {
|
|
|
131
131
|
this.clients.set(this.defaultDb, this.defaultClient);
|
|
132
132
|
await this.defaultClient.connect();
|
|
133
133
|
} catch (error) {
|
|
134
|
-
|
|
134
|
+
logger.error(\`Failed to connect to Redis: \${error}\`);
|
|
135
135
|
throw error;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
@@ -146,8 +146,8 @@ export class RedisConnector {
|
|
|
146
146
|
client = new Redis({ ...this.options, db, lazyConnect: true });
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
client.on('connect', () =>
|
|
150
|
-
client.on('error', (err) =>
|
|
149
|
+
client.on('connect', () => logger.info(\`🔴 Redis connected to db \${db}\`));
|
|
150
|
+
client.on('error', (err) => logger.error(\`Redis error on db \${db}: \${err}\`));
|
|
151
151
|
return client;
|
|
152
152
|
}
|
|
153
153
|
|