feat(backend-defaults): add backend.logger configuration options

Signed-off-by: Thomas Cardonne <thomas.cardonne@adevinta.com>
This commit is contained in:
Thomas Cardonne
2025-08-02 01:08:02 +02:00
parent 4ba9f986d2
commit f244e61d20
14 changed files with 670 additions and 7 deletions
+61 -1
View File
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { HumanDuration } from '@backstage/types';
import { HumanDuration, JsonObject } from '@backstage/types';
export interface Config {
app: {
@@ -790,6 +790,66 @@ export interface Config {
headers?: { [name: string]: string };
};
/**
* Options to configure the default RootLoggerService.
*/
logger?: {
/**
* Configures the global log level for messages.
*
* This can also be configured using the LOG_LEVEL environment variable, which
* takes precedence over this configuration.
*
* Defaults to 'info'.
*/
level?: 'debug' | 'info' | 'warn' | 'error';
/**
* Additional metadata to include with every log entry.
*/
meta?: JsonObject;
/**
* List of logger overrides.
*
* Can be used to configure a different level for logs matching certain criterias.
* For example, it can be used to ignore 'info' logs of given plugins.
*
* @example
*
* ```yaml
* logger:
* level: info
* overrides:
* # For catalog and auth plugins, messages less important than 'warn' will be ignored.
* - matchers:
* plugin: [catalog, auth]
* level: warn
* # Ignore all messages that starts with 'Forget'
* - matchers:
* message: '/^Forget/'
* level: warn
* ```
*/
overrides?: Array<{
/**
* Conditions that must be met to override the log level.
*
* A matcher can be:
*
* - A string (exact match or regex pattern delimited by slashes, e.g. `/pattern/`)
* - A non-string value (compared by strict equality)
* - An array of matchers (returns true if any matcher matches)
*/
matchers: JsonObject;
/**
* Log level to use for matched entries.
*/
level: 'debug' | 'info' | 'warn' | 'error';
}>;
};
/**
* Rate limiting options. Defining this as `true` will enable rate limiting with default values.
*/