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:
Heikki Hellgren
2024-04-13 01:35:47 +03:00
parent 16ef9e59e5
commit d5a1fe189b
285 changed files with 975 additions and 1050 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import { Config } from '@backstage/config';
import { ConfigSchema } from '@backstage/config-loader';
import express from 'express';
import { HttpAuthService } from '@backstage/backend-plugin-api';
import { Logger } from 'winston';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PluginDatabaseManager } from '@backstage/backend-common';
// @public (undocumented)
@@ -26,7 +26,7 @@ export interface RouterOptions {
// (undocumented)
httpAuth?: HttpAuthService;
// (undocumented)
logger: Logger;
logger: LoggerService;
schema?: ConfigSchema;
staticFallbackHandler?: express.Handler;
}
-1
View File
@@ -62,7 +62,6 @@
"knex": "^3.0.0",
"lodash": "^4.17.21",
"luxon": "^3.0.0",
"winston": "^3.2.1",
"yn": "^4.0.0"
},
"devDependencies": {
@@ -19,10 +19,10 @@ import {
resolvePackagePath,
} from '@backstage/backend-common';
import { Knex } from 'knex';
import { Logger } from 'winston';
import { DateTime } from 'luxon';
import partition from 'lodash/partition';
import { StaticAsset, StaticAssetInput, StaticAssetProvider } from './types';
import { LoggerService } from '@backstage/backend-plugin-api';
const migrationsDir = resolvePackagePath(
'@backstage/plugin-app-backend',
@@ -39,7 +39,7 @@ interface StaticAssetRow {
/** @internal */
export interface StaticAssetsStoreOptions {
database: PluginDatabaseManager;
logger: Logger;
logger: LoggerService;
}
/**
@@ -49,7 +49,7 @@ export interface StaticAssetsStoreOptions {
*/
export class StaticAssetsStore implements StaticAssetProvider {
#db: Knex;
#logger: Logger;
#logger: LoggerService;
#namespace: string | null;
static async create(options: StaticAssetsStoreOptions) {
@@ -65,7 +65,7 @@ export class StaticAssetsStore implements StaticAssetProvider {
return new StaticAssetsStore(client, options.logger);
}
private constructor(client: Knex, logger: Logger, namespace?: string) {
private constructor(client: Knex, logger: LoggerService, namespace?: string) {
this.#db = client;
this.#logger = logger;
this.#namespace = namespace ?? null;
+2 -2
View File
@@ -16,7 +16,6 @@
import fs from 'fs-extra';
import { resolve as resolvePath } from 'path';
import { Logger } from 'winston';
import { AppConfig, Config } from '@backstage/config';
import { JsonObject } from '@backstage/types';
import {
@@ -24,12 +23,13 @@ import {
loadConfigSchema,
readEnvConfig,
} from '@backstage/config-loader';
import { LoggerService } from '@backstage/backend-plugin-api';
type InjectOptions = {
appConfigs: AppConfig[];
// Directory of the static JS files to search for file to inject
staticDir: string;
logger: Logger;
logger: LoggerService;
};
/**
+1 -4
View File
@@ -20,7 +20,6 @@ import {
createBackendPlugin,
} from '@backstage/backend-plugin-api';
import { createRouter } from './router';
import { loggerToWinstonLogger } from '@backstage/backend-common';
import {
configSchemaExtensionPoint,
staticFallbackHandlerExtensionPoint,
@@ -72,10 +71,8 @@ export const appPlugin = createBackendPlugin({
const appPackageName =
config.getOptionalString('app.packageName') ?? 'app';
const winstonLogger = loggerToWinstonLogger(logger);
const router = await createRouter({
logger: winstonLogger,
logger,
config,
database,
auth,
+9 -6
View File
@@ -25,12 +25,11 @@ import express from 'express';
import Router from 'express-promise-router';
import fs from 'fs-extra';
import { resolve as resolvePath } from 'path';
import { Logger } from 'winston';
import { injectConfig, readConfigs } from '../lib/config';
import {
StaticAssetsStore,
findStaticAssets,
createStaticAssetMiddleware,
findStaticAssets,
StaticAssetsStore,
} from '../lib/assets';
import {
CACHE_CONTROL_MAX_CACHE,
@@ -38,7 +37,11 @@ import {
CACHE_CONTROL_REVALIDATE_CACHE,
} from '../lib/headers';
import { ConfigSchema } from '@backstage/config-loader';
import { AuthService, HttpAuthService } from '@backstage/backend-plugin-api';
import {
AuthService,
HttpAuthService,
LoggerService,
} from '@backstage/backend-plugin-api';
import { AuthenticationError } from '@backstage/errors';
// express uses mime v1 while we only have types for mime v2
@@ -47,7 +50,7 @@ type Mime = { lookup(arg0: string): string };
/** @public */
export interface RouterOptions {
config: Config;
logger: Logger;
logger: LoggerService;
auth?: AuthService;
httpAuth?: HttpAuthService;
@@ -270,7 +273,7 @@ async function createEntryPointRouter({
appMode,
appConfigs,
}: {
logger: Logger;
logger: LoggerService;
rootDir: string;
assetStore?: StaticAssetsStore;
staticFallbackHandler?: express.Handler;
@@ -15,16 +15,16 @@
*/
import { Server } from 'http';
import { Logger } from 'winston';
import { createServiceBuilder } from '@backstage/backend-common';
import { Config } from '@backstage/config';
import { createRouter } from './router';
import { LoggerService } from '@backstage/backend-plugin-api';
export interface ServerOptions {
port: number;
enableCors: boolean;
config: Config;
logger: Logger;
logger: LoggerService;
}
export async function startStandaloneServer(