5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
- import { experimental , isPromise , json } from '@angular-devkit/core' ;
8
+ import { experimental , isPromise , json , logging } from '@angular-devkit/core' ;
9
9
import { Observable , Subscription , from , isObservable , of } from 'rxjs' ;
10
10
import { tap } from 'rxjs/operators' ;
11
11
import {
@@ -17,6 +17,7 @@ import {
17
17
BuilderProgressState ,
18
18
Target ,
19
19
TypedBuilderProgress ,
20
+ targetStringFromTarget ,
20
21
} from './api' ;
21
22
import { Builder , BuilderSymbol , BuilderVersionSymbol } from './internal' ;
22
23
import { scheduleByName , scheduleByTarget } from './schedule-by-name' ;
@@ -28,13 +29,16 @@ export function createBuilder<OptT extends json.JsonObject>(
28
29
const cjh = experimental . jobs . createJobHandler ;
29
30
const handler = cjh < json . JsonObject , BuilderInput , BuilderOutput > ( ( options , context ) => {
30
31
const scheduler = context . scheduler ;
31
- const logger = context . logger ;
32
32
const progressChannel = context . createChannel ( 'progress' ) ;
33
+ const logChannel = context . createChannel ( 'log' ) ;
33
34
let currentState : BuilderProgressState = BuilderProgressState . Stopped ;
34
35
let current = 0 ;
35
36
let status = '' ;
36
37
let total = 1 ;
37
38
39
+ function log ( entry : logging . LogEntry ) {
40
+ logChannel . next ( entry ) ;
41
+ }
38
42
function progress ( progress : TypedBuilderProgress , context : BuilderContext ) {
39
43
currentState = progress . state ;
40
44
if ( progress . state === BuilderProgressState . Running ) {
@@ -74,6 +78,13 @@ export function createBuilder<OptT extends json.JsonObject>(
74
78
75
79
function onInput ( i : BuilderInput ) {
76
80
const builder = i . info as BuilderInfo ;
81
+ const loggerName = i . target
82
+ ? targetStringFromTarget ( i . target as Target )
83
+ : builder . builderName ;
84
+ const logger = new logging . Logger ( loggerName ) ;
85
+
86
+ subscriptions . push ( logger . subscribe ( entry => log ( entry ) ) ) ;
87
+
77
88
const context : BuilderContext = {
78
89
builder,
79
90
workspaceRoot : i . workspaceRoot ,
0 commit comments