Mostly better logging

This commit is contained in:
2015-05-03 13:29:15 +02:00
parent 294e4ca849
commit 6fa1bd319f
2 changed files with 15 additions and 9 deletions
+3 -1
View File
@@ -110,7 +110,7 @@ function session(sock) {
// Make sure the sequence number is set and is correct // Make sure the sequence number is set and is correct
pduObj.seqNr = returnObj.ourSeqNr; pduObj.seqNr = returnObj.ourSeqNr;
log.debug('larvitsmpp: lib/session.js: session() - returnObj.send() - Sending PDU to remote. cmdName: ' + pduObj.cmdName + ' seqNr: ' + pduObj.seqNr); log.debug('larvitsmpp: lib/session.js: session() - returnObj.send() - Sending PDU to remote. pduObj: ' + JSON.stringify(pduObj));
// If closeAndSend is omitted, put callback in its place // If closeAndSend is omitted, put callback in its place
if (typeof closeAfterSend === 'function') { if (typeof closeAfterSend === 'function') {
@@ -225,6 +225,8 @@ function session(sock) {
pduObj.params.registered_delivery = 0x01; pduObj.params.registered_delivery = 0x01;
} }
log.debug('larvitsmpp: lib/session.js: returnObj.sendSms() - pduObj: ' + JSON.stringify(pduObj));
returnObj.send(pduObj, function(err, retPduObj) { returnObj.send(pduObj, function(err, retPduObj) {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(err, retPduObj.params.message_id, retPduObj); callback(err, retPduObj.params.message_id, retPduObj);
+12 -8
View File
@@ -116,6 +116,8 @@ function writeBuffer(obj, cmdLength, callback) {
// Write parameter value to buffer using the types method write() // Write parameter value to buffer using the types method write()
paramType.write(obj.params[param], buff, offset); paramType.write(obj.params[param], buff, offset);
log.silly('larvitsmpp: lib/utils.js: writeBuffer() - Writing param "' + param + '" with content "' + obj.params[param] + '"');
// Increase the offset for the next param // Increase the offset for the next param
offset += paramType.size(obj.params[param]); offset += paramType.size(obj.params[param]);
} }
@@ -132,7 +134,7 @@ function writeBuffer(obj, cmdLength, callback) {
tlvSize = tlvDef.type.size(tlvValue); tlvSize = tlvDef.type.size(tlvValue);
log.silly('larvitsmpp: lib/utils.js: objToPdu() - writeBuffer() - Writing TLV "' + tlvName + '" offset: ' + offset + ' value: "' + tlvValue + '"'); log.silly('larvitsmpp: lib/utils.js: writeBuffer() - Writing TLV "' + tlvName + '" offset: ' + offset + ' value: "' + tlvValue + '"');
buff.writeUInt16BE(tlvId, offset); buff.writeUInt16BE(tlvId, offset);
buff.writeUInt16BE(tlvSize, offset + 2); buff.writeUInt16BE(tlvSize, offset + 2);
@@ -299,6 +301,8 @@ function pduToObj(pdu, callback) {
'tagName': defs.tlvsById[tlvCmdId].tag, 'tagName': defs.tlvsById[tlvCmdId].tag,
'tagValue': tlvValue 'tagValue': tlvValue
}; };
log.silly('larvitsmpp: lib/utils.js: pduToObj() - TLV found: "' + defs.tlvsById[tlvCmdId].tag + '" ID: "' + tlvCmdId + '" value: "' + tlvValue + '"');
} }
offset = offset + 4 + tlvLength; offset = offset + 4 + tlvLength;
@@ -307,13 +311,11 @@ function pduToObj(pdu, callback) {
// Decode the short message if it is set // Decode the short message if it is set
if (retObj.params.short_message !== undefined) { if (retObj.params.short_message !== undefined) {
retObj.params.short_message = decodeMsg(retObj.params.short_message, retObj.params.data_coding); retObj.params.short_message = decodeMsg(retObj.params.short_message, retObj.params.data_coding);
callback(null, retObj);
} else {
// We need to do the standard callback in an else statement since
// this always would be called before the above callback if we didn't
callback(null, retObj);
} }
log.debug('larvitsmpp: lib/utils.js: pduToObj() - Complete decoded PDU: ' + JSON.stringify(retObj));
callback(null, retObj);
} }
/** /**
@@ -357,7 +359,7 @@ function objToPdu(obj, callback) {
return; return;
} }
// All params are mandatory. Set them if they are not set // Params must be an object
if (obj.params === undefined) { if (obj.params === undefined) {
obj.params = {}; obj.params = {};
} }
@@ -379,6 +381,8 @@ function objToPdu(obj, callback) {
log.silly('larvitsmpp: lib/utils.js: objToPdu() - encoding message "' + shortMsg + '" to "' + obj.params.short_message.toString('hex') + '"'); log.silly('larvitsmpp: lib/utils.js: objToPdu() - encoding message "' + shortMsg + '" to "' + obj.params.short_message.toString('hex') + '"');
} }
log.debug('larvitsmpp: lib/utils.js: objToPdu() - Complete object to encode: ' + JSON.stringify(obj));
calcCmdLength(obj, function(err, cmdLength) { calcCmdLength(obj, function(err, cmdLength) {
if (err) { if (err) {
callback(err); callback(err);