Skip to content

Commit d5a1fe1

Browse files
committed
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>
1 parent 16ef9e5 commit d5a1fe1

File tree

285 files changed

+968
-1043
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+968
-1043
lines changed

.changeset/many-pears-drop.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
'@backstage/plugin-search-backend-module-stack-overflow-collator': patch
3+
'@backstage/plugin-catalog-backend-module-incremental-ingestion': patch
4+
'@backstage/plugin-catalog-backend-module-bitbucket-server': patch
5+
'@backstage/plugin-tech-insights-backend-module-jsonfc': patch
6+
'@backstage/plugin-catalog-backend-module-github-org': patch
7+
'@backstage/plugin-scaffolder-backend-module-github': patch
8+
'@backstage/plugin-catalog-backend-module-puppetdb': patch
9+
'@backstage/plugin-catalog-backend-module-msgraph': patch
10+
'@backstage/plugin-search-backend-module-techdocs': patch
11+
'@backstage/plugin-catalog-backend-module-gerrit': patch
12+
'@backstage/plugin-catalog-backend-module-github': patch
13+
'@backstage/plugin-catalog-backend-module-gitlab': patch
14+
'@backstage/plugin-search-backend-module-explore': patch
15+
'@backstage/plugin-catalog-backend-module-azure': patch
16+
'@backstage/plugin-catalog-backend-module-aws': patch
17+
'@backstage/plugin-catalog-backend-module-gcp': patch
18+
'@backstage/plugin-scaffolder-node-test-utils': patch
19+
'@backstage/plugin-entity-feedback-backend': patch
20+
'@backstage/plugin-code-coverage-backend': patch
21+
'@backstage/plugin-tech-insights-backend': patch
22+
'@backstage/plugin-azure-devops-backend': patch
23+
'@backstage/plugin-azure-sites-backend': patch
24+
'@backstage/plugin-search-backend-node': patch
25+
'@backstage/plugin-kubernetes-backend': patch
26+
'@backstage/plugin-lighthouse-backend': patch
27+
'@backstage/plugin-permission-backend': patch
28+
'@backstage/plugin-tech-insights-node': patch
29+
'@backstage/plugin-sonarqube-backend': patch
30+
'@backstage/backend-app-api': patch
31+
'@backstage/plugin-airbrake-backend': patch
32+
'@backstage/plugin-devtools-backend': patch
33+
'@backstage/plugin-linguist-backend': patch
34+
'@backstage/plugin-periskop-backend': patch
35+
'@backstage/plugin-playlist-backend': patch
36+
'@backstage/plugin-catalog-backend': patch
37+
'@backstage/plugin-explore-backend': patch
38+
'@backstage/plugin-jenkins-backend': patch
39+
'@backstage/plugin-scaffolder-node': patch
40+
'@backstage/backend-tasks': patch
41+
'@backstage/plugin-badges-backend': patch
42+
'@backstage/plugin-bazaar-backend': patch
43+
'@backstage/plugin-search-backend': patch
44+
'@backstage/plugin-kafka-backend': patch
45+
'@backstage/plugin-nomad-backend': patch
46+
'@backstage/plugin-techdocs-node': patch
47+
'@backstage/plugin-todo-backend': patch
48+
'@backstage/plugin-adr-backend': patch
49+
'@backstage/plugin-app-backend': patch
50+
---
51+
52+
Replaced winston logger with `LoggerService`

packages/backend-app-api/src/services/implementations/scheduler/schedulerServiceFactory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { loggerToWinstonLogger } from '@backstage/backend-common';
1817
import {
1918
coreServices,
2019
createServiceFactory,
@@ -33,7 +32,7 @@ export const schedulerServiceFactory = createServiceFactory({
3332
return TaskScheduler.forPlugin({
3433
pluginId: plugin.getId(),
3534
databaseManager,
36-
logger: loggerToWinstonLogger(logger),
35+
logger,
3736
});
3837
},
3938
});

packages/backend-app-api/src/services/implementations/urlReader/urlReaderServiceFactory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { loggerToWinstonLogger, UrlReaders } from '@backstage/backend-common';
17+
import { UrlReaders } from '@backstage/backend-common';
1818
import {
1919
coreServices,
2020
createServiceFactory,
@@ -30,7 +30,7 @@ export const urlReaderServiceFactory = createServiceFactory({
3030
async factory({ config, logger }) {
3131
return UrlReaders.default({
3232
config,
33-
logger: loggerToWinstonLogger(logger),
33+
logger,
3434
});
3535
},
3636
});

packages/backend-tasks/api-report.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Duration } from 'luxon';
88
import { HumanDuration as HumanDuration_2 } from '@backstage/types';
99
import { JsonObject } from '@backstage/types';
1010
import { LegacyRootDatabaseService } from '@backstage/backend-common';
11-
import { Logger } from 'winston';
11+
import { LoggerService } from '@backstage/backend-plugin-api';
1212
import { PluginDatabaseManager } from '@backstage/backend-common';
1313

1414
// @public @deprecated
@@ -83,20 +83,23 @@ export interface TaskScheduleDefinitionConfig {
8383

8484
// @public
8585
export class TaskScheduler {
86-
constructor(databaseManager: LegacyRootDatabaseService, logger: Logger);
86+
constructor(
87+
databaseManager: LegacyRootDatabaseService,
88+
logger: LoggerService,
89+
);
8790
forPlugin(pluginId: string): PluginTaskScheduler;
8891
// (undocumented)
8992
static forPlugin(opts: {
9093
pluginId: string;
9194
databaseManager: PluginDatabaseManager;
92-
logger: Logger;
95+
logger: LoggerService;
9396
}): PluginTaskScheduler;
9497
// (undocumented)
9598
static fromConfig(
9699
config: Config,
97100
options?: {
98101
databaseManager?: LegacyRootDatabaseService;
99-
logger?: Logger;
102+
logger?: LoggerService;
100103
},
101104
): TaskScheduler;
102105
}

packages/backend-tasks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@backstage/backend-common": "workspace:^",
36+
"@backstage/backend-plugin-api": "workspace:^",
3637
"@backstage/config": "workspace:^",
3738
"@backstage/errors": "workspace:^",
3839
"@backstage/types": "workspace:^",
@@ -43,7 +44,6 @@
4344
"lodash": "^4.17.21",
4445
"luxon": "^3.0.0",
4546
"uuid": "^9.0.0",
46-
"winston": "^3.2.1",
4747
"zod": "^3.22.4"
4848
},
4949
"devDependencies": {

packages/backend-tasks/src/tasks/LocalTaskWorker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import { ConflictError } from '@backstage/errors';
1818
import { CronTime } from 'cron';
1919
import { DateTime, Duration } from 'luxon';
20-
import { Logger } from 'winston';
2120
import { TaskFunction, TaskSettingsV2 } from './types';
2221
import { delegateAbortController, sleep } from './util';
22+
import { LoggerService } from '@backstage/backend-plugin-api';
2323

2424
/**
2525
* Implements tasks that run locally without cross-host collaboration.
@@ -32,7 +32,7 @@ export class LocalTaskWorker {
3232
constructor(
3333
private readonly taskId: string,
3434
private readonly fn: TaskFunction,
35-
private readonly logger: Logger,
35+
private readonly logger: LoggerService,
3636
) {}
3737

3838
start(settings: TaskSettingsV2, options?: { signal?: AbortSignal }) {

packages/backend-tasks/src/tasks/PluginTaskSchedulerImpl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616

1717
import { Knex } from 'knex';
1818
import { Duration } from 'luxon';
19-
import { Logger } from 'winston';
2019
import { LocalTaskWorker } from './LocalTaskWorker';
2120
import { TaskWorker } from './TaskWorker';
2221
import {
2322
PluginTaskScheduler,
2423
TaskDescriptor,
24+
TaskFunction,
2525
TaskInvocationDefinition,
2626
TaskRunner,
2727
TaskScheduleDefinition,
2828
TaskSettingsV2,
2929
} from './types';
3030
import { validateId } from './util';
31-
import { TaskFunction } from './types';
32-
import { metrics, Counter, Histogram } from '@opentelemetry/api';
31+
import { Counter, Histogram, metrics } from '@opentelemetry/api';
32+
import { LoggerService } from '@backstage/backend-plugin-api';
3333

3434
/**
3535
* Implements the actual task management.
@@ -43,7 +43,7 @@ export class PluginTaskSchedulerImpl implements PluginTaskScheduler {
4343

4444
constructor(
4545
private readonly databaseFactory: () => Promise<Knex>,
46-
private readonly logger: Logger,
46+
private readonly logger: LoggerService,
4747
) {
4848
const meter = metrics.getMeter('default');
4949
this.counter = meter.createCounter('backend_tasks.task.runs.count', {

packages/backend-tasks/src/tasks/PluginTaskSchedulerJanitor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
import { Knex } from 'knex';
1818
import { Duration } from 'luxon';
19-
import { Logger } from 'winston';
20-
import { DbTasksRow, DB_TASKS_TABLE } from '../database/tables';
19+
import { DB_TASKS_TABLE, DbTasksRow } from '../database/tables';
2120
import { sleep } from './util';
21+
import { LoggerService } from '@backstage/backend-plugin-api';
2222

2323
/**
2424
* Makes sure to auto-expire and clean up things that time out or for other
@@ -27,12 +27,12 @@ import { sleep } from './util';
2727
export class PluginTaskSchedulerJanitor {
2828
private readonly knex: Knex;
2929
private readonly waitBetweenRuns: Duration;
30-
private readonly logger: Logger;
30+
private readonly logger: LoggerService;
3131

3232
constructor(options: {
3333
knex: Knex;
3434
waitBetweenRuns: Duration;
35-
logger: Logger;
35+
logger: LoggerService;
3636
}) {
3737
this.knex = options.knex;
3838
this.waitBetweenRuns = options.waitBetweenRuns;

packages/backend-tasks/src/tasks/TaskScheduler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import {
2323
import { Config } from '@backstage/config';
2424
import { once } from 'lodash';
2525
import { Duration } from 'luxon';
26-
import { Logger } from 'winston';
2726
import { migrateBackendTasks } from '../database/migrateBackendTasks';
2827
import { PluginTaskSchedulerImpl } from './PluginTaskSchedulerImpl';
2928
import { PluginTaskSchedulerJanitor } from './PluginTaskSchedulerJanitor';
3029
import { PluginTaskScheduler } from './types';
30+
import { LoggerService } from '@backstage/backend-plugin-api';
3131

3232
/**
3333
* Deals with the scheduling of distributed tasks.
@@ -39,7 +39,7 @@ export class TaskScheduler {
3939
config: Config,
4040
options?: {
4141
databaseManager?: LegacyRootDatabaseService;
42-
logger?: Logger;
42+
logger?: LoggerService;
4343
},
4444
): TaskScheduler {
4545
const databaseManager =
@@ -52,7 +52,7 @@ export class TaskScheduler {
5252

5353
constructor(
5454
private readonly databaseManager: LegacyRootDatabaseService,
55-
private readonly logger: Logger,
55+
private readonly logger: LoggerService,
5656
) {}
5757

5858
/**
@@ -72,7 +72,7 @@ export class TaskScheduler {
7272
static forPlugin(opts: {
7373
pluginId: string;
7474
databaseManager: PluginDatabaseManager;
75-
logger: Logger;
75+
logger: LoggerService;
7676
}): PluginTaskScheduler {
7777
const databaseFactory = once(async () => {
7878
const knex = await opts.databaseManager.getClient();

packages/backend-tasks/src/tasks/TaskWorker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import { CronTime } from 'cron';
1919
import { Knex } from 'knex';
2020
import { DateTime, Duration } from 'luxon';
2121
import { v4 as uuid } from 'uuid';
22-
import { Logger } from 'winston';
23-
import { DbTasksRow, DB_TASKS_TABLE } from '../database/tables';
22+
import { DB_TASKS_TABLE, DbTasksRow } from '../database/tables';
2423
import { TaskFunction, TaskSettingsV2, taskSettingsV2Schema } from './types';
2524
import { delegateAbortController, nowPlus, sleep } from './util';
25+
import { LoggerService } from '@backstage/backend-plugin-api';
2626

2727
const DEFAULT_WORK_CHECK_FREQUENCY = Duration.fromObject({ seconds: 5 });
2828

@@ -36,7 +36,7 @@ export class TaskWorker {
3636
private readonly taskId: string,
3737
private readonly fn: TaskFunction,
3838
private readonly knex: Knex,
39-
private readonly logger: Logger,
39+
private readonly logger: LoggerService,
4040
private readonly workCheckFrequency: Duration = DEFAULT_WORK_CHECK_FREQUENCY,
4141
) {}
4242

0 commit comments

Comments
 (0)