Skip to content

Commit

Permalink
logger
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net committed Aug 6, 2024
1 parent e415f6c commit 09b33a7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/backend/src/core/AdvancedSearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { LoggerService } from '@/core/LoggerService.js';
import { isQuote, isRenote } from '@/misc/is-renote.js';
import { isReply } from '@/misc/is-reply.js';
import { DriveService } from './DriveService.js';
import type Logger from '@/logger.js';

type openSearchHit = {

Check failure on line 26 in packages/backend/src/core/AdvancedSearchService.ts

View workflow job for this annotation

GitHub Actions / lint (backend)

Type Alias name `openSearchHit` must match one of the following formats: PascalCase
_index: string
Expand Down Expand Up @@ -82,6 +83,7 @@ const retryLimit = 2;
@Injectable()
export class AdvancedSearchService {
private opensearchNoteIndex: string | null = null;
private logger: Logger;

constructor(
@Inject(DI.config)
Expand All @@ -102,6 +104,7 @@ export class AdvancedSearchService {
private loggerService: LoggerService,
private driveService: DriveService,
) {
this.logger = this.loggerService.getLogger('search');
if (opensearch && config.opensearch && config.opensearch.index) {
const indexname = `${config.opensearch.index}---notes`;
this.opensearchNoteIndex = indexname;
Expand Down Expand Up @@ -161,14 +164,14 @@ export class AdvancedSearchService {
},
},
}).catch((error) => {
this.loggerService.getLogger('search').error(error);
this.logger.error(error);
}),
];
}).catch((error) => {
this.loggerService.getLogger('search').error(error);
this.logger.error(error);
});
} else {
this.loggerService.getLogger('search').info('OpenSearch is not available');
this.logger.info('OpenSearch is not available');
this.opensearchNoteIndex = null;
}
}
Expand Down Expand Up @@ -207,7 +210,7 @@ export class AdvancedSearchService {
id: note.id,
body: body,
}).catch((error) => {
this.loggerService.getLogger('search').error(error);
this.logger.error(error);
});
}
}
Expand All @@ -222,7 +225,7 @@ export class AdvancedSearchService {
await this.redisClient.set('indexDeleted', 'deleted', 'EX', 300);
await this.opensearch.indices.delete({
index: this.opensearchNoteIndex as string }).catch((error) => {
this.loggerService.getLogger('search').error(error);
this.logger.error(error);
return;
});

Expand Down Expand Up @@ -278,14 +281,14 @@ export class AdvancedSearchService {
},
},
}).catch((error) => {
this.loggerService.getLogger('search').error(error);
this.logger.error(error);
return;
});

await this.redisClient.del('indexDeleted');
this.loggerService.getLogger('search').info('reIndexing.');
this.logger.info('reIndexing.');
this.fullIndexNote().catch((error) => {
this.loggerService.getLogger('search').error(error);
this.logger.error(error);
return;
});
}
Expand All @@ -299,7 +302,7 @@ export class AdvancedSearchService {
const limit = 100;
let latestid = '';
for (let index = 0; index < notesCount; index += limit) {
this.loggerService.getLogger('search').info('indexing' + index + '/' + notesCount);
this.logger.info('indexing' + index + '/' + notesCount);

const notes = await this.notesRepository
.createQueryBuilder('note')
Expand All @@ -312,7 +315,7 @@ export class AdvancedSearchService {
latestid = note.id;
});
}
this.loggerService.getLogger('search').info('All notes has been indexed.');
this.logger.info('All notes has been indexed.');
}

@bindThis
Expand Down

0 comments on commit 09b33a7

Please sign in to comment.