refactor: start deprecating legacy service helpers
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
+3
-2
@@ -25,10 +25,11 @@ export const cacheServiceFactory = createServiceFactory({
|
||||
service: coreServices.cache,
|
||||
deps: {
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.rootLogger,
|
||||
plugin: coreServices.pluginMetadata,
|
||||
},
|
||||
async createRootContext({ config }) {
|
||||
return CacheManager.fromConfig(config);
|
||||
async createRootContext({ config, logger }) {
|
||||
return CacheManager.fromConfig(config, { logger });
|
||||
},
|
||||
async factory({ plugin }, manager) {
|
||||
return manager.forPlugin(plugin.getId()).getClient();
|
||||
|
||||
@@ -218,7 +218,7 @@ export function cacheToPluginCacheManager(
|
||||
cache: CacheClient,
|
||||
): PluginCacheManager;
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export const coloredFormat: winston.Logform.Format;
|
||||
|
||||
// @public
|
||||
@@ -259,7 +259,7 @@ export function createLegacyAuthAdapters<
|
||||
: {}),
|
||||
>(options: TOptions): TAdapters;
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export function createRootLogger(
|
||||
options?: winston.LoggerOptions,
|
||||
env?: NodeJS.ProcessEnv,
|
||||
@@ -366,10 +366,10 @@ export class GerritUrlReader implements UrlReader {
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export function getRootLogger(): winston.Logger;
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export function getVoidLogger(): winston.Logger;
|
||||
|
||||
// @public @deprecated
|
||||
@@ -815,7 +815,7 @@ export type ServiceBuilder = {
|
||||
start(): Promise<Server>;
|
||||
};
|
||||
|
||||
// @public
|
||||
// @public @deprecated
|
||||
export function setRootLogger(newLogger: winston.Logger): void;
|
||||
|
||||
// @public @deprecated
|
||||
|
||||
@@ -72,6 +72,8 @@ export class CacheManager {
|
||||
config.getOptionalString('backend.cache.connection') || '';
|
||||
const useRedisSets =
|
||||
config.getOptionalBoolean('backend.cache.useRedisSets') ?? true;
|
||||
|
||||
// TODO: Make logger required and remove the default logger after moving this class to the `backstage-defaults`package
|
||||
const logger = (options.logger || getRootLogger()).child({
|
||||
type: 'cacheManager',
|
||||
});
|
||||
|
||||
@@ -59,6 +59,8 @@ const colorizer = format.colorize();
|
||||
* Creates a pretty printed winston log formatter.
|
||||
*
|
||||
* @public
|
||||
* @deprecated As we are going to deprecate the legacy backend, this formatter utility will be removed in the future.
|
||||
* If you need to format logs in the new system, please use the `WinstonLogger.colorFormat()` from `@backstage/backend-app-api` instead.
|
||||
*/
|
||||
export const coloredFormat = format.combine(
|
||||
format.timestamp(),
|
||||
@@ -96,6 +98,9 @@ export const coloredFormat = format.combine(
|
||||
* instances passed to plugins etc, in a given backend.
|
||||
*
|
||||
* @public
|
||||
* @deprecated As we are going to deprecate the legacy backend, this function will be removed in the future.
|
||||
* If you need to create the root logger in the new system, please check out this documentation:
|
||||
* https://backstage.io/docs/backend-system/core-services/logger
|
||||
*/
|
||||
export function createRootLogger(
|
||||
options: winston.LoggerOptions = {},
|
||||
|
||||
@@ -21,6 +21,8 @@ import { createRootLogger } from './createRootLogger';
|
||||
* A logger that just throws away all messages.
|
||||
*
|
||||
* @public
|
||||
* @deprecated As we are going to deprecate the legacy backend, this function will be removed in the future.
|
||||
* If you need to mock the root logger in the new system, please use `mockServices.logger.mock()` from `@backstage/test-utils` instead.
|
||||
*/
|
||||
export function getVoidLogger(): winston.Logger {
|
||||
return winston.createLogger({
|
||||
@@ -34,6 +36,9 @@ let rootLogger: winston.Logger;
|
||||
* Gets the current root logger.
|
||||
*
|
||||
* @public
|
||||
* @deprecated As we are going to deprecate the legacy backend, this function will be removed in the future.
|
||||
* If you need to get the root logger in the new system, please check out this documentation:
|
||||
* https://backstage.io/docs/backend-system/core-services/logger
|
||||
*/
|
||||
export function getRootLogger(): winston.Logger {
|
||||
if (!rootLogger) {
|
||||
@@ -55,6 +60,9 @@ export function getRootLogger(): winston.Logger {
|
||||
* behavior, you would instead call {@link createRootLogger}.
|
||||
*
|
||||
* @public
|
||||
* @deprecated As we are going to deprecate the legacy backend, this function will be removed in the future.
|
||||
* If you need to set the root logger in the new system, please check out this documentation:
|
||||
* https://backstage.io/docs/backend-system/core-services/logger
|
||||
*/
|
||||
export function setRootLogger(newLogger: winston.Logger) {
|
||||
rootLogger = newLogger;
|
||||
|
||||
@@ -94,7 +94,7 @@ export class TaskScheduler {
|
||||
databaseManager: PluginDatabaseManager;
|
||||
logger: LoggerService;
|
||||
}): PluginTaskScheduler;
|
||||
// (undocumented)
|
||||
// @deprecated (undocumented)
|
||||
static fromConfig(
|
||||
config: Config,
|
||||
options?: {
|
||||
|
||||
@@ -35,6 +35,10 @@ import { LoggerService } from '@backstage/backend-plugin-api';
|
||||
* @public
|
||||
*/
|
||||
export class TaskScheduler {
|
||||
/**
|
||||
* @deprecated
|
||||
* It is only used by the legacy backend system, and should not be used in the new backend system.
|
||||
*/
|
||||
static fromConfig(
|
||||
config: Config,
|
||||
options?: {
|
||||
|
||||
Reference in New Issue
Block a user