File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 22 * Copyright (c) Microsoft Corporation. All rights reserved.
33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
5+ let Subscriber : ( message : string ) => void ;
6+
7+ export function SubscribeToAllLoggers ( subscriber : ( message :string ) => void ) {
8+ Subscriber = subscriber ;
9+ }
510
611export class Logger {
712 private _writer : ( message : string ) => void ;
@@ -20,17 +25,17 @@ export class Logger {
2025 if ( this . _atLineStart ) {
2126 if ( this . _indentLevel > 0 ) {
2227 const indent = " " . repeat ( this . _indentLevel * this . _indentSize ) ;
23- this . _writer ( indent ) ;
28+ this . write ( indent ) ;
2429 }
2530
2631 if ( this . _prefix ) {
27- this . _writer ( `[${ this . _prefix } ] ` ) ;
32+ this . write ( `[${ this . _prefix } ] ` ) ;
2833 }
2934
3035 this . _atLineStart = false ;
3136 }
3237
33- this . _writer ( message ) ;
38+ this . write ( message ) ;
3439 }
3540
3641 public increaseIndent ( ) : void {
@@ -53,4 +58,12 @@ export class Logger {
5358 this . _appendCore ( message + '\n' ) ;
5459 this . _atLineStart = true ;
5560 }
61+
62+ private write ( message : string ) {
63+ this . _writer ( message ) ;
64+
65+ if ( Subscriber ) {
66+ Subscriber ( message ) ;
67+ }
68+ }
5669}
Original file line number Diff line number Diff line change 33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ import { SubscribeToAllLoggers } from "../../src/logger" ;
67//
78// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
89//
@@ -26,4 +27,6 @@ testRunner.configure({
2627 useColors : true // colored output from test results
2728} ) ;
2829
30+ SubscribeToAllLoggers ( message => console . log ( message ) ) ;
31+
2932module . exports = testRunner ;
Original file line number Diff line number Diff line change 33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ import { SubscribeToAllLoggers } from "../../src/logger" ;
67//
78// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
89//
@@ -26,4 +27,6 @@ testRunner.configure({
2627 useColors : true // colored output from test results
2728} ) ;
2829
30+ SubscribeToAllLoggers ( message => console . log ( message ) ) ;
31+
2932module . exports = testRunner ;
You can’t perform that action at this time.
0 commit comments