Skip to content
This repository
Browse code

Fixup log messages to exclude the function name

  • Loading branch information...
commit 161e530641375ddc7cf164cfbde1d6cc4e76c321 1 parent 5ffb619
Dhruv Matani authored June 15, 2012
3  src/bosh-event-emitter.js
@@ -28,6 +28,9 @@ var util        = require('util');
28 28
 var dutil       = require('./dutil.js');
29 29
 var us          = require('underscore');
30 30
 
  31
+var filename    = path.basename(path.normalize(__filename));
  32
+var log         = require('./log.js').getLogger(filename);
  33
+
31 34
 function BoshEventPipe(http_server) {
32 35
     this.server = http_server;
33 36
 }
50  src/session.js
@@ -220,9 +220,9 @@ Session.prototype = {
220 220
         }
221 221
 
222 222
         // Null out all the requests for the deleted stream.
223  
-        us(this.queued_requests).each(function (queued_request, rid) {
  223
+        us(this.queued_requests).each(function stream_request_deleter(queued_request, rid) {
224 224
             if (queued_request.stream === stream) {
225  
-                log.trace("%s %s delete_stream - will not process request rid: %s", this.sid, stream.name, rid);
  225
+                log.trace("%s %s Will not process request rid: %s", this.sid, stream.name, rid);
226 226
                 this.queued_requests[rid].node = $body();
227 227
                 this.queued_requests[rid].stream = null;
228 228
             }
@@ -449,7 +449,7 @@ Session.prototype = {
449 449
             var condition = 'policy-violation';
450 450
             this.send_terminate_response(ro, condition);
451 451
 
452  
-            this.streams.forEach(function (stream) {
  452
+            this.streams.forEach(function stream_terminator(stream) {
453 453
                 stream.terminate(condition);
454 454
             });
455 455
 
@@ -458,7 +458,7 @@ Session.prototype = {
458 458
         }
459 459
 
460 460
         ro.set_socket_options(this.wait);
461  
-        ro.set_timeout(function () {
  461
+        ro.set_timeout(function _on_request_timeout_callback() {
462 462
             var pos = this.res.indexOf(ro);
463 463
             if (pos === -1) {
464 464
                 return;
@@ -524,8 +524,8 @@ Session.prototype = {
524 524
         log.trace("%s reset_inactivity_timeout - %s sec", this.sid, this.inactivity + 10);
525 525
 
526 526
         var self = this;
527  
-        this.timeout = setTimeout(function () {
528  
-            log.info("%s terminating Session due to inactivity", self.sid);
  527
+        this.timeout = setTimeout(function _on_session_inactivity_timeout_callback() {
  528
+            log.info("%s Terminating Session due to inactivity", self.sid);
529 529
             // Raise a no-client event on pending, unstitched as well as unacked 
530 530
             // responses.
531 531
             var _p = us.pluck(self.pending_stitched_responses, 'response');
@@ -728,7 +728,7 @@ Session.prototype = {
728 728
         return response;
729 729
     },
730 730
     
731  
-    _stitch_new_response: function _stitch_new_response() {
  731
+    _stitch_new_response: function () {
732 732
         var len = this.streams.length;
733 733
         this.next_stream = this.next_stream % len;
734 734
         log.trace("%s _stitch_new_response - #streams: %s, next_stream: %s", this.sid, len, this.next_stream);
@@ -771,8 +771,8 @@ Session.prototype = {
771 771
     // degrade the experience for the client. Hence, we stick with
772 772
     // the current implementation.
773 773
     //
774  
-    send_pending_responses: function send_pending_responses() {
775  
-        log.trace("%s send_pending_responses - pending.length: %s, Holding %s response objects", 
  774
+    send_pending_responses: function () {
  775
+        log.trace("%s pending.length: %s, Holding %s response objects", 
776 776
                   this.sid, this.pending_stitched_responses.length, this.res.length);
777 777
 
778 778
         while (true) {
@@ -808,7 +808,7 @@ Session.prototype = {
808 808
     // If and when a new HTTP request on this BOSH session is detected,
809 809
     // it will clear the pending response and send the packet
810 810
     // (in FIFO order).
811  
-    _on_no_client_found: function _on_no_client_found(response, stream) {
  811
+    _on_no_client_found: function (response, stream) {
812 812
         var _po = {
813 813
             response: response,
814 814
             stream: stream
@@ -816,7 +816,7 @@ Session.prototype = {
816 816
         this.pending_stitched_responses.push(_po);
817 817
     },
818 818
 
819  
-    try_sending: function try_sending() {
  819
+    try_sending: function () {
820 820
         if (!this.has_next_tick) {
821 821
             process.nextTick(function () {
822 822
                 this.has_next_tick = false;
@@ -839,7 +839,7 @@ Session.prototype = {
839 839
      */
840 840
 
841 841
     enqueue_bosh_response: function (attrs, stream) {
842  
-        log.trace("%s %s enqueue_bosh_response", this.sid, stream.name);
  842
+        log.trace("%s %s", this.sid, stream.name);
843 843
         this.pending_bosh_responses[stream.name].push(attrs);
844 844
 
845 845
         if (this._options.PIDGIN_COMPATIBLE && this.first_response) {
@@ -850,7 +850,7 @@ Session.prototype = {
850 850
     },
851 851
 
852 852
     enqueue_stanza: function (stanza, stream) {
853  
-        log.trace("%s %s enqueue_stanza", this.sid, stream.name);
  853
+        log.trace("%s %s", this.sid, stream.name);
854 854
         this.pending_stanzas[stream.name].push(stanza);
855 855
         this.try_sending();
856 856
     },
@@ -871,12 +871,12 @@ Session.prototype = {
871 871
 
872 872
     // Send a response, but do NOT requeue if it fails
873 873
     _send_no_requeue: function (ro, msg) {
874  
-        log.trace("%s _send_no_requeue::ro: %s", this.sid, !!ro);
  874
+        log.trace("%s ro: %s", this.sid, !!ro);
875 875
         if (us.isFalsy(ro)) {
876 876
             return;
877 877
         }
878 878
 
879  
-        log.trace("%s _send_no_requeue::ro.rid: %s, this.rid: %s", this.sid, ro.rid, this.rid);
  879
+        log.trace("%s ro.rid: %s, this.rid: %s", this.sid, ro.rid, this.rid);
880 880
 
881 881
         var ack = this._get_highest_rid_to_ack(ro.rid);
882 882
 
@@ -936,7 +936,7 @@ Session.prototype = {
936 936
      */
937 937
     _get_random_stream: function () {
938 938
         if (this.streams.length === 0) {
939  
-            log.error("%s get_random_stream - session has no streams", this.sid);
  939
+            log.error("%s session has no streams", this.sid);
940 940
             return null;
941 941
         }
942 942
         var stream = this.streams[0];
@@ -948,7 +948,7 @@ Session.prototype = {
948 948
      * not in sequence.
949 949
      */
950 950
     _send_immediate: function (res, response_obj) {
951  
-        log.trace("%s send_immediate - ro: %s", this.sid, !!response_obj);
  951
+        log.trace("%s ro: %s", this.sid, !!response_obj);
952 952
         var ro = new responsejs.Response(res, null, this.sid, this._options);
953 953
         ro.send_response(response_obj.toString());
954 954
     },
@@ -989,7 +989,7 @@ Session.prototype = {
989 989
         _uar_keys.forEach(function purge_acknowledged_responses(rid) {
990 990
             if (rid <= node.attrs.ack) {
991 991
                 // Raise the 'response-acknowledged' event.
992  
-                log.trace("%s handle_acks - received ack: %s", this.sid, rid);
  992
+                log.trace("%s received ack: %s", this.sid, rid);
993 993
                 this._bep.emit('response-acknowledged',
994 994
                                this.unacked_responses[rid], this);
995 995
                 delete this.unacked_responses[rid];
@@ -1010,13 +1010,13 @@ Session.prototype = {
1010 1010
             var _ts = this.unacked_responses[node.attrs.ack].ts;
1011 1011
             var stream = this._get_random_stream();
1012 1012
             if (!stream) {
1013  
-                log.error("%s enqueue_report_if_reqd - couldnt get random stream", this.sid);
  1013
+                log.error("%s Couldn't get random stream", this.sid);
1014 1014
             } else {
1015 1015
                 // We inject a response packet into the pending queue to
1016 1016
                 // notify the client that it _may_ have missed something.
1017 1017
                 // TODO: we should also have a check which ensures that 
1018 1018
                 // time > RTT has passed. 
1019  
-                log.trace("%s enqueue_report_if_reqd - sending report - max_rid_sent: %s, node.attrs.ack: %s", 
  1019
+                log.trace("%s Sending report - max_rid_sent: %s, node.attrs.ack: %s", 
1020 1020
                           this.sid, this.max_rid_sent, node.attrs.ack);
1021 1021
                 this.enqueue_bosh_response({
1022 1022
                     report: node.attrs.ack + 1,
@@ -1057,7 +1057,7 @@ Session.prototype = {
1057 1057
         // A. No idea - will need to think about it. However, a
1058 1058
         // standard for loop seems more readable here.
1059 1059
         // 
1060  
-        _queued_request_keys.forEach(function (rid) {
  1060
+        _queued_request_keys.forEach(function _handle_broken_queued_requests(rid) {
1061 1061
             // There should be exactly 1 'rid' in state.queued_requests
1062 1062
             // that is less than state.rid + 1. -- such requests are
1063 1063
             // immediately returned (processed and deleted by this 
@@ -1066,14 +1066,14 @@ Session.prototype = {
1066 1066
             if (rid < self.rid + 1) {
1067 1067
                 assert(rid === node.attrs.rid);
1068 1068
 
1069  
-                log.trace("%s handle_broken_connections - queued_req.rid: %s, state.rid: %s", self.sid, rid, self.rid);
  1069
+                log.trace("%s queued_req::rid: %s, state.rid: %s", self.sid, rid, self.rid);
1070 1070
                 delete self.queued_requests[rid];
1071 1071
                 is_broken = true;
1072 1072
                 if (self.unacked_responses.hasOwnProperty(rid)) {
1073 1073
                     //
1074 1074
                     // Send back the original response on this conection itself
1075 1075
                     //
1076  
-                    log.trace("%s handle_broken_connections - resending unacked response: %s", self.sid, rid);
  1076
+                    log.trace("%s Resending unacked response: %s", self.sid, rid);
1077 1077
                     self._send_immediate(res, self.unacked_responses[rid].response);
1078 1078
                 } else if (rid >= self.rid - self.window - 2) {
1079 1079
                     //
@@ -1085,7 +1085,7 @@ Session.prototype = {
1085 1085
                     // body the second time around. The client is to be blamed for its
1086 1086
                     // stupidity and not us.
1087 1087
                     //
1088  
-                    log.trace("%s handle_broken_connections sending empty body for rid(out of range): %s", self.sid, rid);
  1088
+                    log.trace("%s Sending empty body for rid(out of range): %s", self.sid, rid);
1089 1089
                     self._send_immediate(res, $body());
1090 1090
 
1091 1091
                 } else {
@@ -1099,7 +1099,7 @@ Session.prototype = {
1099 1099
                     //
1100 1100
                     // Note: Control DOES reach here. We need to figure out WHY.
1101 1101
                     //
1102  
-                    log.error("%s handle_broken_connections - terminating due to out of bound rid: %s, session.rid: %s", self.sid, rid, self.rid);
  1102
+                    log.error("%s Terminating due to out of bound rid: %s, session.rid: %s", self.sid, rid, self.rid);
1103 1103
                     dutil.copy(node.attrs, { //TODO: Might be moved to helper.
1104 1104
                         type: 'terminate',
1105 1105
                         condition: 'item-not-found',

0 notes on commit 161e530

Please sign in to comment.
Something went wrong with that request. Please try again.