@@ -91,7 +91,7 @@ RequestClient.prototype.request = function(opts) {
91
91
} ;
92
92
93
93
if ( opts . logLevel === 'debug' ) {
94
- logRequest ( options )
94
+ this . logRequest ( options )
95
95
}
96
96
97
97
var _this = this ;
@@ -102,7 +102,6 @@ RequestClient.prototype.request = function(opts) {
102
102
if ( opts . logLevel === 'debug' ) {
103
103
console . log ( `response.statusCode: ${ response . status } ` )
104
104
console . log ( `response.headers: ${ JSON . stringify ( response . headers ) } ` )
105
- console . log ( `response.data: ${ JSON . stringify ( response . data ) } ` )
106
105
}
107
106
_this . lastResponse = new Response ( response . status , response . data , response . headers ) ;
108
107
deferred . resolve ( {
@@ -117,23 +116,25 @@ RequestClient.prototype.request = function(opts) {
117
116
return deferred . promise ;
118
117
} ;
119
118
120
- function logRequest ( options ) {
119
+ RequestClient . prototype . filterLoggingHeaders = function ( headers ) {
120
+ return Object . keys ( headers ) . filter ( ( header ) => {
121
+ return ! 'authorization' . includes ( header . toLowerCase ( ) ) ;
122
+ } ) ;
123
+ }
124
+
125
+ RequestClient . prototype . logRequest = function ( options ) {
121
126
console . log ( '-- BEGIN Twilio API Request --' ) ;
122
127
console . log ( `${ options . method } ${ options . url } ` ) ;
123
128
124
- if ( options . data ) {
125
- console . log ( 'Form data:' ) ;
126
- console . log ( options . data ) ;
127
- }
128
-
129
129
if ( options . params ) {
130
130
console . log ( 'Querystring:' ) ;
131
131
console . log ( options . params ) ;
132
132
}
133
133
134
134
if ( options . headers ) {
135
135
console . log ( 'Headers:' ) ;
136
- console . log ( options . headers )
136
+ const filteredHeaderKeys = this . filterLoggingHeaders ( options . headers ) ;
137
+ filteredHeaderKeys . forEach ( ( header ) => console . log ( `${ header } : ${ options . headers [ header ] } ` ) ) ;
137
138
}
138
139
139
140
console . log ( '-- END Twilio API Request --' ) ;
0 commit comments