@soulcraft/brainy 0.54.4 → 0.54.5

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.
@@ -14,6 +14,7 @@ import { NounType, VerbType } from './types/graphTypes.js';
14
14
  import { createServerSearchAugmentations } from './augmentations/serverSearchAugmentations.js';
15
15
  import { IntelligentVerbScoring } from './augmentations/intelligentVerbScoring.js';
16
16
  import { augmentationPipeline } from './augmentationPipeline.js';
17
+ import { prodLog } from './utils/logger.js';
17
18
  import { prepareJsonForVectorization, extractFieldFromJson } from './utils/jsonProcessing.js';
18
19
  import { DistributedConfigManager, HashPartitioner, OperationalModeFactory, DomainDetector, HealthMonitor } from './distributed/index.js';
19
20
  import { SearchCache } from './utils/searchCache.js';
@@ -197,7 +198,7 @@ export class BrainyData {
197
198
  };
198
199
  }
199
200
  if (this.loggingConfig?.verbose) {
200
- console.log(this.cacheAutoConfigurator.getConfigExplanation(autoConfig));
201
+ prodLog.info(this.cacheAutoConfigurator.getConfigExplanation(autoConfig));
201
202
  }
202
203
  }
203
204
  // Initialize search cache with final configuration
@@ -252,7 +253,7 @@ export class BrainyData {
252
253
  // If the database is frozen, do not start real-time updates
253
254
  if (this.frozen) {
254
255
  if (this.loggingConfig?.verbose) {
255
- console.log('Real-time updates disabled: database is frozen');
256
+ prodLog.info('Real-time updates disabled: database is frozen');
256
257
  }
257
258
  return;
258
259
  }
@@ -266,16 +267,16 @@ export class BrainyData {
266
267
  this.lastKnownNounCount = count;
267
268
  })
268
269
  .catch((error) => {
269
- console.warn('Failed to get initial noun count for real-time updates:', error);
270
+ prodLog.warn('Failed to get initial noun count for real-time updates:', error);
270
271
  });
271
272
  // Start the update timer
272
273
  this.updateTimerId = setInterval(() => {
273
274
  this.checkForUpdates().catch((error) => {
274
- console.warn('Error during real-time update check:', error);
275
+ prodLog.warn('Error during real-time update check:', error);
275
276
  });
276
277
  }, this.realtimeUpdateConfig.interval);
277
278
  if (this.loggingConfig?.verbose) {
278
- console.log(`Real-time updates started with interval: ${this.realtimeUpdateConfig.interval}ms`);
279
+ prodLog.info(`Real-time updates started with interval: ${this.realtimeUpdateConfig.interval}ms`);
279
280
  }
280
281
  }
281
282
  /**
@@ -290,7 +291,7 @@ export class BrainyData {
290
291
  clearInterval(this.updateTimerId);
291
292
  this.updateTimerId = null;
292
293
  if (this.loggingConfig?.verbose) {
293
- console.log('Real-time updates stopped');
294
+ prodLog.info('Real-time updates stopped');
294
295
  }
295
296
  }
296
297
  /**
@@ -332,7 +333,7 @@ export class BrainyData {
332
333
  await this.metadataIndex.flush();
333
334
  }
334
335
  catch (error) {
335
- console.warn('Error flushing metadata index:', error);
336
+ prodLog.warn('Error flushing metadata index:', error);
336
337
  }
337
338
  }, 30000); // Flush every 30 seconds
338
339
  // Store the interval ID for cleanup
@@ -394,7 +395,7 @@ export class BrainyData {
394
395
  // Cleanup expired cache entries (defensive mechanism for distributed scenarios)
395
396
  const expiredCount = this.searchCache.cleanupExpiredEntries();
396
397
  if (expiredCount > 0 && this.loggingConfig?.verbose) {
397
- console.log(`Cleaned up ${expiredCount} expired cache entries`);
398
+ prodLog.debug(`Cleaned up ${expiredCount} expired cache entries`);
398
399
  }
399
400
  // Adapt cache configuration based on performance (every few updates)
400
401
  // Only adapt every 5th update to avoid over-optimization
@@ -407,11 +408,11 @@ export class BrainyData {
407
408
  this.lastUpdateTime = Date.now();
408
409
  if (this.loggingConfig?.verbose) {
409
410
  const duration = this.lastUpdateTime - startTime;
410
- console.log(`Real-time update completed in ${duration}ms`);
411
+ prodLog.debug(`Real-time update completed in ${duration}ms`);
411
412
  }
412
413
  }
413
414
  catch (error) {
414
- console.error('Failed to check for updates:', error);
415
+ prodLog.error('Failed to check for updates:', error);
415
416
  // Don't rethrow the error to avoid disrupting the update timer
416
417
  }
417
418
  }
@@ -437,7 +438,7 @@ export class BrainyData {
437
438
  const noun = change.data;
438
439
  // Check if the vector dimensions match the expected dimensions
439
440
  if (noun.vector.length !== this._dimensions) {
440
- console.warn(`Skipping noun ${noun.id} due to dimension mismatch: expected ${this._dimensions}, got ${noun.vector.length}`);
441
+ prodLog.warn(`Skipping noun ${noun.id} due to dimension mismatch: expected ${this._dimensions}, got ${noun.vector.length}`);
441
442
  continue;
442
443
  }
443
444
  // Add or update in index
@@ -452,7 +453,7 @@ export class BrainyData {
452
453
  updatedCount++;
453
454
  }
454
455
  if (this.loggingConfig?.verbose) {
455
- console.log(`${change.operation === 'add' ? 'Added' : 'Updated'} noun ${noun.id} in index during real-time update`);
456
+ prodLog.debug(`${change.operation === 'add' ? 'Added' : 'Updated'} noun ${noun.id} in index during real-time update`);
456
457
  }
457
458
  }
458
459
  break;