Commit 01c3f4e253d964bd3a7aed2137962c805550629a
1 parent
80d5f6d276
Exists in
master
logging using logger
Showing 1 changed file with 13 additions and 10 deletions Side-by-side Diff
partner-trugee.js
... | ... | @@ -40,13 +40,12 @@ function createPayload(task) { |
40 | 40 | ] |
41 | 41 | }; |
42 | 42 | |
43 | - console.log(payload); | |
43 | + //console.log(payload); | |
44 | 44 | return "<?xml version=\"1.0\" ?>\n" + xml(payload); |
45 | 45 | } |
46 | 46 | |
47 | 47 | function topupRequest(task, retry) { |
48 | 48 | |
49 | - console.log('Requesting to partner:'); | |
50 | 49 | var payload_xml = createPayload(task); |
51 | 50 | var partner = url.parse(config.h2h_out.partner); |
52 | 51 | |
... | ... | @@ -62,9 +61,12 @@ function topupRequest(task, retry) { |
62 | 61 | }; |
63 | 62 | |
64 | 63 | var buffer = ""; |
64 | + | |
65 | + logger.info('Requesting to partner', {request_options: request_options}); | |
66 | + | |
65 | 67 | var req = http.request(request_options, function( res ) { |
66 | 68 | |
67 | - console.log('Status code: ' + res.statusCode ); | |
69 | + logger.info('Status code: ' + res.statusCode ); | |
68 | 70 | var buffer = ""; |
69 | 71 | res.on( "data", function( data ) { buffer = buffer + data; } ); |
70 | 72 | res.on( "end", function( data ) { |
... | ... | @@ -74,23 +76,25 @@ function topupRequest(task, retry) { |
74 | 76 | }); |
75 | 77 | |
76 | 78 | req.on('error', function(e) { |
77 | - console.log('problem with request: ' + e.message); | |
79 | + logger.warn('problem with request: ' + e.message); | |
78 | 80 | callbackReport(task['requestId'], '40', e.message); |
79 | 81 | }); |
80 | 82 | |
83 | + logger.verbose('Sending payload to partner', {payload: payload_xml}); | |
81 | 84 | req.write( payload_xml ); |
82 | 85 | req.end(); |
83 | 86 | } |
84 | 87 | |
85 | 88 | function directResponseHandler(body, request_id) { |
86 | - console.log('Direct Response:'); | |
89 | + logger.info('Got direct response'); | |
87 | 90 | xml2js(body, function (err, result) { |
88 | 91 | if (err) { |
89 | - console.log(body); | |
92 | + logger.warn('Error parsing xml', {body: body}); | |
90 | 93 | callbackReport(request_id, '40', buffer); |
91 | 94 | return; |
92 | 95 | } |
93 | - console.log(result); | |
96 | + | |
97 | + logger.info('Direct response parsed', {result: result}); | |
94 | 98 | |
95 | 99 | var response_code = '68'; |
96 | 100 | |
... | ... | @@ -132,9 +136,8 @@ function createServer() { |
132 | 136 | |
133 | 137 | res.end('OK'); |
134 | 138 | |
135 | - console.log('Reverse Report:'); | |
136 | 139 | var qs = url.parse(req.url, true).query; |
137 | - console.log(qs); | |
140 | + logger.info('Reverse Report', {qs: qs}); | |
138 | 141 | |
139 | 142 | var response_code = '68'; |
140 | 143 | var request_id = qs.pid; |
... | ... | @@ -162,7 +165,7 @@ function createServer() { |
162 | 165 | }); |
163 | 166 | |
164 | 167 | httpServer.listen(config.h2h_out.listen_port, function() { |
165 | - console.log('HTTP Reverse/Report server listen on port ' + config.h2h_out.listen_port); | |
168 | + logger.info('HTTP Reverse/Report server listen on port ' + config.h2h_out.listen_port); | |
166 | 169 | }); |
167 | 170 | } |
168 | 171 |