@@ -50,12 +50,14 @@ import HTTPClient from './HTTPClient/HTTPClient';
50
50
import CommunicationProtocolEnum from '../../enum/CommunicationProtocol.enum' ;
51
51
import { DaprClientOptions } from '../../types/DaprClientOptions' ;
52
52
import { Settings } from '../../utils/Settings.util' ;
53
+ import { Logger } from '../../logger/Logger' ;
53
54
54
55
export default class DaprClient {
55
56
readonly daprHost : string ;
56
57
readonly daprPort : string ;
57
58
readonly options : DaprClientOptions ;
58
59
readonly communicationProtocol : CommunicationProtocolEnum ;
60
+ readonly logger : Logger ;
59
61
60
62
readonly daprClient : IClient ;
61
63
readonly pubsub : IClientPubSub ;
@@ -74,13 +76,14 @@ export default class DaprClient {
74
76
, daprPort ?: string
75
77
, communicationProtocol : CommunicationProtocolEnum = CommunicationProtocolEnum . HTTP
76
78
, options : DaprClientOptions = {
77
- isKeepAlive : true
78
- }
79
+ isKeepAlive : true ,
80
+ } ,
79
81
) {
80
82
this . daprHost = daprHost ?? Settings . getDefaultHost ( ) ;
81
83
this . daprPort = daprPort ?? Settings . getDefaultPort ( communicationProtocol ) ;
82
84
this . communicationProtocol = communicationProtocol ;
83
85
this . options = options ;
86
+ this . logger = new Logger ( this . options . loggerOptions ) ;
84
87
85
88
// Validation on port
86
89
if ( ! / ^ [ 0 - 9 ] + $ / . test ( this . daprPort ) ) {
@@ -90,11 +93,11 @@ export default class DaprClient {
90
93
// Builder
91
94
switch ( communicationProtocol ) {
92
95
case CommunicationProtocolEnum . GRPC : {
93
- const client = new GRPCClient ( this . daprHost , this . daprPort , this . options ) ;
96
+ const client = new GRPCClient ( this . daprHost , this . daprPort , this . options , this . logger ) ;
94
97
this . daprClient = client ;
95
98
96
99
this . state = new GRPCClientState ( client ) ;
97
- this . pubsub = new GRPCClientPubSub ( client ) ;
100
+ this . pubsub = new GRPCClientPubSub ( client , this . logger ) ;
98
101
this . binding = new GRPCClientBinding ( client ) ;
99
102
this . invoker = new GRPCClientInvoker ( client ) ;
100
103
this . secret = new GRPCClientSecret ( client ) ;
@@ -107,11 +110,11 @@ export default class DaprClient {
107
110
}
108
111
case CommunicationProtocolEnum . HTTP :
109
112
default : {
110
- const client = new HTTPClient ( this . daprHost , this . daprPort , this . options ) ;
113
+ const client = new HTTPClient ( this . daprHost , this . daprPort , this . options , this . logger ) ;
111
114
this . daprClient = client ;
112
115
113
116
this . state = new HTTPClientState ( client ) ;
114
- this . pubsub = new HTTPClientPubSub ( client ) ;
117
+ this . pubsub = new HTTPClientPubSub ( client , this . logger ) ;
115
118
this . binding = new HTTPClientBinding ( client ) ;
116
119
this . invoker = new HTTPClientInvoker ( client ) ;
117
120
this . secret = new HTTPClientSecret ( client ) ;
0 commit comments