chore: change most of plugins to use LoggerService
quite a big PR for this but the changes are pretty stright forward. hopefully gets merged before most of these plugins move to the community repository. Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
@@ -18,15 +18,15 @@ import {
|
||||
DocumentDecoratorFactory,
|
||||
DocumentTypeInfo,
|
||||
} from '@backstage/plugin-search-common';
|
||||
import { Transform, pipeline } from 'stream';
|
||||
import { Logger } from 'winston';
|
||||
import { pipeline, Transform } from 'stream';
|
||||
import { Scheduler } from './Scheduler';
|
||||
import {
|
||||
SearchEngine,
|
||||
IndexBuilderOptions,
|
||||
RegisterCollatorParameters,
|
||||
RegisterDecoratorParameters,
|
||||
SearchEngine,
|
||||
} from './types';
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* Used for adding collators, decorators and compile them into tasks which are added to a scheduler returned to the caller.
|
||||
@@ -37,7 +37,7 @@ export class IndexBuilder {
|
||||
private decorators: Record<string, DocumentDecoratorFactory[]>;
|
||||
private documentTypes: Record<string, DocumentTypeInfo>;
|
||||
private searchEngine: SearchEngine;
|
||||
private logger: Logger;
|
||||
private logger: LoggerService;
|
||||
|
||||
constructor(options: IndexBuilderOptions) {
|
||||
this.collators = {};
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Logger } from 'winston';
|
||||
import { TaskFunction, TaskRunner } from '@backstage/backend-tasks';
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
|
||||
type TaskEnvelope = {
|
||||
task: TaskFunction;
|
||||
@@ -37,12 +37,12 @@ export type ScheduleTaskParameters = {
|
||||
* @public
|
||||
*/
|
||||
export class Scheduler {
|
||||
private logger: Logger;
|
||||
private logger: LoggerService;
|
||||
private schedule: { [id: string]: TaskEnvelope };
|
||||
private abortControllers: AbortController[];
|
||||
private isRunning: boolean;
|
||||
|
||||
constructor(options: { logger: Logger }) {
|
||||
constructor(options: { logger: LoggerService }) {
|
||||
this.logger = options.logger;
|
||||
this.schedule = {};
|
||||
this.abortControllers = [];
|
||||
|
||||
@@ -14,25 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Logger } from 'winston';
|
||||
|
||||
import {
|
||||
createServiceRef,
|
||||
createServiceFactory,
|
||||
coreServices,
|
||||
createExtensionPoint,
|
||||
createServiceFactory,
|
||||
createServiceRef,
|
||||
LoggerService,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import { DocumentTypeInfo } from '@backstage/plugin-search-common';
|
||||
import { createExtensionPoint } from '@backstage/backend-plugin-api';
|
||||
|
||||
import {
|
||||
IndexBuilder,
|
||||
RegisterCollatorParameters,
|
||||
RegisterDecoratorParameters,
|
||||
} from '@backstage/plugin-search-backend-node';
|
||||
|
||||
import {
|
||||
SearchEngine,
|
||||
IndexBuilder,
|
||||
} from '@backstage/plugin-search-backend-node';
|
||||
|
||||
/**
|
||||
@@ -78,7 +73,7 @@ export interface SearchEngineRegistryExtensionPoint {
|
||||
}
|
||||
|
||||
type DefaultSearchIndexServiceOptions = {
|
||||
logger: Logger;
|
||||
logger: LoggerService;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -86,7 +81,7 @@ type DefaultSearchIndexServiceOptions = {
|
||||
* Reponsible for register the indexing task and start the schedule.
|
||||
*/
|
||||
class DefaultSearchIndexService implements SearchIndexService {
|
||||
private logger: Logger;
|
||||
private logger: LoggerService;
|
||||
private indexBuilder: IndexBuilder | null = null;
|
||||
|
||||
private constructor(options: DefaultSearchIndexServiceOptions) {
|
||||
@@ -134,7 +129,7 @@ export const searchIndexServiceRef = createServiceRef<SearchIndexService>({
|
||||
},
|
||||
factory({ logger }) {
|
||||
return DefaultSearchIndexService.fromConfig({
|
||||
logger: loggerToWinstonLogger(logger),
|
||||
logger,
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
import { Config } from '@backstage/config';
|
||||
import { DocumentCollatorFactory } from '@backstage/plugin-search-common';
|
||||
import { Logger } from 'winston';
|
||||
import { Permission } from '@backstage/plugin-permission-common';
|
||||
import { Readable } from 'stream';
|
||||
import { UrlReader } from '@backstage/backend-common';
|
||||
import { parse as parseNdjson } from 'ndjson';
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* Options for instantiate NewlineDelimitedJsonCollatorFactory
|
||||
@@ -30,7 +30,7 @@ export type NewlineDelimitedJsonCollatorFactoryOptions = {
|
||||
type: string;
|
||||
searchPattern: string;
|
||||
reader: UrlReader;
|
||||
logger: Logger;
|
||||
logger: LoggerService;
|
||||
visibilityPermission?: Permission;
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ export class NewlineDelimitedJsonCollatorFactory
|
||||
type: string,
|
||||
private readonly searchPattern: string,
|
||||
private readonly reader: UrlReader,
|
||||
private readonly logger: Logger,
|
||||
private readonly logger: LoggerService,
|
||||
visibilityPermission: Permission | undefined,
|
||||
) {
|
||||
this.type = type;
|
||||
|
||||
@@ -19,12 +19,12 @@ import {
|
||||
IndexableResultSet,
|
||||
SearchQuery,
|
||||
} from '@backstage/plugin-search-common';
|
||||
import { SearchEngine, QueryTranslator } from '../types';
|
||||
import { QueryTranslator, SearchEngine } from '../types';
|
||||
import { MissingIndexError } from '../errors';
|
||||
import lunr from 'lunr';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { Logger } from 'winston';
|
||||
import { LunrSearchEngineIndexer } from './LunrSearchEngineIndexer';
|
||||
import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
|
||||
/**
|
||||
* Type of translated query for the Lunr Search Engine.
|
||||
@@ -54,11 +54,11 @@ export type LunrQueryTranslator = (query: SearchQuery) => ConcreteLunrQuery;
|
||||
export class LunrSearchEngine implements SearchEngine {
|
||||
protected lunrIndices: Record<string, lunr.Index> = {};
|
||||
protected docStore: Record<string, IndexableDocument>;
|
||||
protected logger: Logger;
|
||||
protected logger: LoggerService;
|
||||
protected highlightPreTag: string;
|
||||
protected highlightPostTag: string;
|
||||
|
||||
constructor(options: { logger: Logger }) {
|
||||
constructor(options: { logger: LoggerService }) {
|
||||
this.logger = options.logger;
|
||||
this.docStore = {};
|
||||
const uuidTag = uuid();
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { BackstageCredentials } from '@backstage/backend-plugin-api';
|
||||
import {
|
||||
BackstageCredentials,
|
||||
LoggerService,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { TaskRunner } from '@backstage/backend-tasks';
|
||||
import {
|
||||
DocumentCollatorFactory,
|
||||
@@ -23,7 +26,6 @@ import {
|
||||
SearchQuery,
|
||||
} from '@backstage/plugin-search-common';
|
||||
import { Writable } from 'stream';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
/**
|
||||
* Options required to instantiate the index builder.
|
||||
@@ -31,7 +33,7 @@ import { Logger } from 'winston';
|
||||
*/
|
||||
export type IndexBuilderOptions = {
|
||||
searchEngine: SearchEngine;
|
||||
logger: Logger;
|
||||
logger: LoggerService;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user