Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/angular/ssr/src/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@

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.
*
* This class extends the internal Angular `ɵConsole` class to provide customized logging behavior.
* 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);
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/angular/ssr/src/routes/ng-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
]);
Expand Down
Loading