File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 8
8
9
9
import { ɵConsole } from '@angular/core' ;
10
10
11
+ /**
12
+ * A set of log messages that should be ignored and not printed to the console.
13
+ */
14
+ const IGNORED_LOGS = new Set ( [ 'Angular is running in development mode.' ] ) ;
15
+
11
16
/**
12
17
* Custom implementation of the Angular Console service that filters out specific log messages.
13
18
*
14
19
* This class extends the internal Angular `ɵConsole` class to provide customized logging behavior.
15
20
* It overrides the `log` method to suppress logs that match certain predefined messages.
16
21
*/
17
22
export class Console extends ɵConsole {
18
- /**
19
- * A set of log messages that should be ignored and not printed to the console.
20
- */
21
- private readonly ignoredLogs = new Set ( [ 'Angular is running in development mode.' ] ) ;
22
-
23
23
/**
24
24
* Logs a message to the console if it is not in the set of ignored messages.
25
25
*
26
26
* @param message - The message to log to the console.
27
27
*
28
28
* This method overrides the `log` method of the `ɵConsole` class. It checks if the
29
- * message is in the `ignoredLogs ` set. If it is not, it delegates the logging to
29
+ * message is in the `IGNORED_LOGS ` set. If it is not, it delegates the logging to
30
30
* the parent class's `log` method. Otherwise, the message is suppressed.
31
31
*/
32
32
override log ( message : string ) : void {
33
- if ( ! this . ignoredLogs . has ( message ) ) {
33
+ if ( ! IGNORED_LOGS . has ( message ) ) {
34
34
super . log ( message ) ;
35
35
}
36
36
}
Original file line number Diff line number Diff line change @@ -476,7 +476,11 @@ export async function getRoutesFromAngularRouterConfig(
476
476
useValue : { document, url : `${ protocol } //${ host } /` } ,
477
477
} ,
478
478
{
479
+ // An Angular Console Provider that does not print a set of predefined logs.
479
480
provide : ɵConsole ,
481
+ // Using `useClass` would necessitate decorating `Console` with `@Injectable`,
482
+ // which would require switching from `ts_library` to `ng_module`. This change
483
+ // would also necessitate various patches of `@angular/bazel` to support ESM.
480
484
useFactory : ( ) => new Console ( ) ,
481
485
} ,
482
486
] ) ;
You can’t perform that action at this time.
0 commit comments