mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 02:54:21 +08:00
refactor(@angular/ssr): move ignored messages as a global
Refactored the ignored log messages into a global constant.
This commit is contained in:
parent
210bf4e2b4
commit
6eed4609f4
@ -8,6 +8,11 @@
|
||||
|
||||
import { ɵConsole } from '@angular/core';
|
||||
|
||||
/**
|
||||
* A set of log messages that should be ignored and not printed to the console.
|
||||
*/
|
||||
const IGNORED_LOGS = new Set(['Angular is running in development mode.']);
|
||||
|
||||
/**
|
||||
* Custom implementation of the Angular Console service that filters out specific log messages.
|
||||
*
|
||||
@ -15,22 +20,17 @@ import { ɵConsole } from '@angular/core';
|
||||
* It overrides the `log` method to suppress logs that match certain predefined messages.
|
||||
*/
|
||||
export class Console extends ɵConsole {
|
||||
/**
|
||||
* A set of log messages that should be ignored and not printed to the console.
|
||||
*/
|
||||
private readonly ignoredLogs = new Set(['Angular is running in development mode.']);
|
||||
|
||||
/**
|
||||
* Logs a message to the console if it is not in the set of ignored messages.
|
||||
*
|
||||
* @param message - The message to log to the console.
|
||||
*
|
||||
* This method overrides the `log` method of the `ɵConsole` class. It checks if the
|
||||
* message is in the `ignoredLogs` set. If it is not, it delegates the logging to
|
||||
* message is in the `IGNORED_LOGS` set. If it is not, it delegates the logging to
|
||||
* the parent class's `log` method. Otherwise, the message is suppressed.
|
||||
*/
|
||||
override log(message: string): void {
|
||||
if (!this.ignoredLogs.has(message)) {
|
||||
if (!IGNORED_LOGS.has(message)) {
|
||||
super.log(message);
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +476,11 @@ export async function getRoutesFromAngularRouterConfig(
|
||||
useValue: { document, url: `${protocol}//${host}/` },
|
||||
},
|
||||
{
|
||||
// An Angular Console Provider that does not print a set of predefined logs.
|
||||
provide: ɵConsole,
|
||||
// Using `useClass` would necessitate decorating `Console` with `@Injectable`,
|
||||
// which would require switching from `ts_library` to `ng_module`. This change
|
||||
// would also necessitate various patches of `@angular/bazel` to support ESM.
|
||||
useFactory: () => new Console(),
|
||||
},
|
||||
]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user