Delete WinstonLogger from backend-defaults, instead import from backend-defaults

Co-authored-by: Camila Belo <camilaibs@gmail.com>
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2024-08-14 14:11:05 +02:00
parent 070828a4f4
commit 5cee28573e
7 changed files with 16 additions and 162 deletions
-32
View File
@@ -4,15 +4,10 @@
```ts
import { BackendFeature } from '@backstage/backend-plugin-api';
import { Format } from 'logform';
import { IdentityService } from '@backstage/backend-plugin-api';
import { JsonObject } from '@backstage/types';
import { LoggerService } from '@backstage/backend-plugin-api';
import { RootLoggerService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceFactoryCompat } from '@backstage/backend-plugin-api';
import { TokenManagerService } from '@backstage/backend-plugin-api';
import { transport } from 'winston';
// @public (undocumented)
export interface Backend {
@@ -62,31 +57,4 @@ export const tokenManagerServiceFactory: ServiceFactoryCompat<
'singleton',
undefined
>;
// @public @deprecated
export class WinstonLogger implements RootLoggerService {
// (undocumented)
addRedactions(redactions: Iterable<string>): void;
// (undocumented)
child(meta: JsonObject): LoggerService;
static colorFormat(): Format;
static create(options: WinstonLoggerOptions): WinstonLogger;
// (undocumented)
debug(message: string, meta?: JsonObject): void;
// (undocumented)
error(message: string, meta?: JsonObject): void;
// (undocumented)
info(message: string, meta?: JsonObject): void;
static redacter(): {
format: Format;
add: (redactions: Iterable<string>) => void;
};
// (undocumented)
warn(message: string, meta?: JsonObject): void;
}
// Warning: (ae-forgotten-export) The symbol "WinstonLoggerOptions_2" needs to be exported by the entry point index.d.ts
//
// @public @deprecated (undocumented)
export type WinstonLoggerOptions = WinstonLoggerOptions_2;
```
-1
View File
@@ -20,6 +20,5 @@
* @packageDocumentation
*/
export * from './logging';
export * from './wiring';
export * from './services/implementations';
@@ -1,92 +0,0 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import {
WinstonLogger as _WinstonLogger,
type WinstonLoggerOptions as _WinstonLoggerOptions,
} from '../../../backend-defaults/src/entrypoints/rootLogger';
import {
LoggerService,
RootLoggerService,
} from '@backstage/backend-plugin-api';
import { JsonObject } from '@backstage/types';
import { Format } from 'logform';
/**
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootLogger` instead.
*/
export type WinstonLoggerOptions = _WinstonLoggerOptions;
/**
* A {@link @backstage/backend-plugin-api#LoggerService} implementation based on winston.
*
* @public
* @deprecated Please import from `@backstage/backend-defaults/rootLogger` instead.
*/
export class WinstonLogger implements RootLoggerService {
/**
* Creates a {@link WinstonLogger} instance.
*/
static create(options: WinstonLoggerOptions): WinstonLogger {
return new WinstonLogger(_WinstonLogger.create(options));
}
/**
* Creates a winston log formatter for redacting secrets.
*/
static redacter(): {
format: Format;
add: (redactions: Iterable<string>) => void;
} {
return _WinstonLogger.redacter();
}
/**
* Creates a pretty printed winston log formatter.
*/
static colorFormat(): Format {
return _WinstonLogger.colorFormat();
}
private constructor(private readonly impl: _WinstonLogger) {}
error(message: string, meta?: JsonObject): void {
this.impl.error(message, meta);
}
warn(message: string, meta?: JsonObject): void {
this.impl.warn(message, meta);
}
info(message: string, meta?: JsonObject): void {
this.impl.info(message, meta);
}
debug(message: string, meta?: JsonObject): void {
this.impl.debug(message, meta);
}
child(meta: JsonObject): LoggerService {
return this.impl.child(meta);
}
addRedactions(redactions: Iterable<string>) {
this.impl.addRedactions(redactions);
}
}
@@ -1,18 +0,0 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { WinstonLogger } from './WinstonLogger';
export type { WinstonLoggerOptions } from './WinstonLogger';
@@ -15,7 +15,7 @@
*/
// eslint-disable-next-line @backstage/no-relative-monorepo-imports
import { WinstonLogger } from '../../../../backend-app-api/src/logging/WinstonLogger';
import { WinstonLogger } from '../../../../backend-defaults/src/entrypoints/rootLogger/WinstonLogger';
import { merge } from 'lodash';
import * as winston from 'winston';
import { format, LoggerOptions } from 'winston';
@@ -7,14 +7,16 @@
"publishConfig": {
"access": "public"
},
"keywords": [
"backstage"
],
"homepage": "https://backstage.io",
"repository": {
"type": "git",
"url": "https://github.com/backstage/backstage",
"directory": "packages/backend-dynamic-feature-service"
},
"backstage": {
"role": "node-library"
},
"license": "Apache-2.0",
"exports": {
".": "./src/index.ts",
"./package.json": "./package.json"
@@ -26,23 +28,23 @@
]
}
},
"homepage": "https://backstage.io",
"keywords": [
"backstage"
"files": [
"dist",
"config.d.ts"
],
"license": "Apache-2.0",
"scripts": {
"build": "backstage-cli package build",
"clean": "backstage-cli package clean",
"lint": "backstage-cli package lint",
"test": "backstage-cli package test",
"prepack": "backstage-cli package prepack",
"postpack": "backstage-cli package postpack",
"clean": "backstage-cli package clean",
"start": "backstage-cli package start"
"start": "backstage-cli package start",
"test": "backstage-cli package test"
},
"dependencies": {
"@backstage/backend-app-api": "workspace:^",
"@backstage/backend-common": "workspace:^",
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-plugin-api": "workspace:^",
"@backstage/backend-tasks": "workspace:^",
"@backstage/cli-common": "workspace:^",
@@ -70,13 +72,8 @@
"winston": "^3.2.1"
},
"devDependencies": {
"@backstage/backend-defaults": "workspace:^",
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"wait-for-expect": "^3.0.2"
},
"files": [
"dist",
"config.d.ts"
]
}
}
}
@@ -18,7 +18,7 @@ import {
createServiceFactory,
coreServices,
} from '@backstage/backend-plugin-api';
import { WinstonLogger } from '@backstage/backend-app-api';
import { WinstonLogger } from '@backstage/backend-defaults/rootLogger';
import { transports, format } from 'winston';
import { createConfigSecretEnumerator } from '@backstage/backend-common';
import { loadConfigSchema } from '@backstage/config-loader';