switched all console logs to logger

This commit is contained in:
Boki 2025-06-23 11:34:58 -04:00
parent 3877902ff4
commit a3f2f199b4
14 changed files with 125 additions and 122 deletions

View file

@ -13,7 +13,8 @@ export class ServiceCache implements CacheProvider {
constructor(
serviceName: string,
redisConfig: RedisConfig,
isGlobalCache: boolean = false
isGlobalCache: boolean = false,
logger?: any
) {
// Get service configuration
const serviceConfig = getServiceConfig(serviceName);
@ -42,6 +43,7 @@ export class ServiceCache implements CacheProvider {
db,
},
keyPrefix: prefix + ':',
logger,
};
this.cache = createCache(cacheConfig);
@ -161,7 +163,7 @@ export class ServiceCache implements CacheProvider {
export function createServiceCache(
serviceName: string,
redisConfig: RedisConfig,
options: { global?: boolean } = {}
options: { global?: boolean; logger?: any } = {}
): ServiceCache {
return new ServiceCache(serviceName, redisConfig, options.global);
return new ServiceCache(serviceName, redisConfig, options.global, options.logger);
}

View file

@ -14,6 +14,7 @@ import type {
ShutdownOptions,
ShutdownResult,
} from './types';
import { getLogger } from '@stock-bot/logger';
// Global flag that works across all processes/workers
declare global {
@ -22,6 +23,7 @@ declare global {
export class Shutdown {
private static instance: Shutdown | null = null;
private readonly logger = getLogger('shutdown');
private isShuttingDown = false;
private signalReceived = false; // Track if shutdown signal was received
private shutdownTimeout = 30000; // 30 seconds default
@ -200,7 +202,7 @@ export class Shutdown {
} catch (error) {
failed++;
if (name) {
console.error(`Shutdown failed: ${name} (priority: ${priority})`, error);
this.logger.error(`Shutdown failed: ${name} (priority: ${priority})`, error);
}
}
}