@backstage/backend-defaults
Version:
Backend defaults used by Backstage backend apps
82 lines (77 loc) • 2.59 kB
TypeScript
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
import { RootLoggerService, LoggerService } from '@backstage/backend-plugin-api';
import { JsonPrimitive, JsonObject } from '@backstage/types';
import { Format } from 'logform';
import { transport, config } from 'winston';
/**
* Root-level logging.
*
* See {@link @backstage/backend-plugin-api#RootLoggerService}
* and {@link https://backstage.io/docs/backend-system/core-services/root-logger | the service docs}
* for more information.
*
* @public
*/
declare const rootLoggerServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api.RootLoggerService, "root", "singleton">;
/**
* @public
*/
type WinstonLoggerLevelOverrideMatchers = {
[key: string]: JsonPrimitive | JsonPrimitive[] | undefined;
};
/**
* @public
*/
type WinstonLoggerLevelOverride = {
matchers: WinstonLoggerLevelOverrideMatchers;
level: string;
};
/**
* @public
*/
interface WinstonLoggerOptions {
meta?: JsonObject;
level?: string;
format?: Format;
transports?: transport[];
}
/**
* A {@link @backstage/backend-plugin-api#LoggerService} implementation based on winston.
*
* @public
*/
declare class WinstonLogger implements RootLoggerService {
#private;
/**
* Creates a {@link WinstonLogger} instance.
*/
static create(options: WinstonLoggerOptions): WinstonLogger;
/**
* Creates a winston log formatter for redacting secrets.
*/
static redacter(): {
format: Format;
add: (redactions: Iterable<string>) => void;
};
/**
* Creates a pretty printed winston log formatter.
*/
static colorFormat(): Format;
/**
* Formatter that filters log levels using overrides, falling back to the default level when no criteria match.
*/
static logLevelFilter(defaultLogLevel: keyof config.NpmConfigSetLevels): {
format: Format;
setOverrides: (overrides: WinstonLoggerLevelOverride[]) => void;
};
private constructor();
error(message: string, meta?: JsonObject): void;
warn(message: string, meta?: JsonObject): void;
info(message: string, meta?: JsonObject): void;
debug(message: string, meta?: JsonObject): void;
child(meta: JsonObject): LoggerService;
addRedactions(redactions: Iterable<string>): void;
setLevelOverrides(overrides: WinstonLoggerLevelOverride[]): void;
}
export { WinstonLogger, rootLoggerServiceFactory };
export type { WinstonLoggerLevelOverride, WinstonLoggerLevelOverrideMatchers, WinstonLoggerOptions };