Browse code

core: moved log_raw_messages to trsp_socket::log_level_raw_msgs.

Raphael Coeffic authored on 03/02/2012 17:19:35
Showing 5 changed files
... ...
@@ -55,7 +55,6 @@
55 55
 #include "AmEventDispatcher.h"
56 56
 #include "AmSipEvent.h"
57 57
 
58
-int SipCtrlInterface::log_raw_messages = 3;
59 58
 bool SipCtrlInterface::log_parsed_messages = true;
60 59
 int SipCtrlInterface::udp_rcvbuf = -1;
61 60
 
... ...
@@ -82,14 +81,14 @@ int SipCtrlInterface::load()
82 81
 
83 82
 	if (cfg.hasParameter("log_raw_messages")) {
84 83
 	    string msglog = cfg.getParameter("log_raw_messages");
85
-	    if (msglog == "no") log_raw_messages = -1;
86
-	    else if (msglog == "error") log_raw_messages = 0;
87
-	    else if (msglog == "warn")  log_raw_messages = 1;
88
-	    else if (msglog == "info")  log_raw_messages = 2;
89
-	    else if (msglog == "debug") log_raw_messages = 3;
84
+	    if (msglog == "no") trsp_socket::log_level_raw_msgs = -1;
85
+	    else if (msglog == "error") trsp_socket::log_level_raw_msgs = L_ERR;
86
+	    else if (msglog == "warn")  trsp_socket::log_level_raw_msgs = L_WARN;
87
+	    else if (msglog == "info")  trsp_socket::log_level_raw_msgs = L_INFO;
88
+	    else if (msglog == "debug") trsp_socket::log_level_raw_msgs = L_DBG;
90 89
 	}
91 90
 	DBG("log_raw_messages level = %d\n", 
92
-	    log_raw_messages);
91
+	    trsp_socket::log_level_raw_msgs);
93 92
 
94 93
 	if (cfg.hasParameter("log_parsed_messages")) {
95 94
 	    log_parsed_messages = cfg.getParameter("log_parsed_messages")=="yes";
... ...
@@ -72,7 +72,6 @@ public:
72 72
     static string outbound_host;
73 73
     static unsigned int outbound_port;
74 74
     static bool log_parsed_messages;
75
-    static int log_raw_messages;
76 75
     static int udp_rcvbuf;
77 76
 
78 77
     SipCtrlInterface();
... ...
@@ -34,6 +34,8 @@
34 34
 #include <netinet/in.h>
35 35
 #include <string.h> // memset, strerror, ...
36 36
 
37
+int trsp_socket::log_level_raw_msgs = L_DBG;
38
+
37 39
 trsp_socket::trsp_socket(unsigned short if_num)
38 40
     : sd(0), ip(), port(0), if_num(if_num)
39 41
 {
... ...
@@ -97,9 +99,8 @@ unsigned short trsp_socket::get_if()
97 99
 
98 100
 int trsp_socket::send(const sockaddr_storage* sa, const char* msg, const int msg_len)
99 101
 {
100
-    if ((SipCtrlInterface::log_raw_messages >= 0)
101
-	&& (SipCtrlInterface::log_raw_messages <= log_level)) {
102
-	_LOG(SipCtrlInterface::log_raw_messages, 
102
+    if (log_level_raw_msgs >= 0) {
103
+	_LOG(log_level_raw_msgs, 
103 104
 	     "send  msg\n--++--\n%.*s--++--\n", msg_len, msg);
104 105
     }
105 106
 
... ...
@@ -43,6 +43,9 @@ using std::string;
43 43
 
44 44
 class trsp_socket
45 45
 {
46
+public:
47
+    static int log_level_raw_msgs;
48
+    
46 49
 protected:
47 50
     // socket descriptor
48 51
     int sd;
... ...
@@ -207,8 +207,8 @@ void udp_trsp::run()
207 207
 	}
208 208
 	sip_msg* s_msg = new sip_msg(buf,buf_len);
209 209
 
210
-	if (SipCtrlInterface::log_raw_messages >= 0) {
211
-	    _LOG(SipCtrlInterface::log_raw_messages, 
210
+	if (trsp_socket::log_level_raw_msgs >= 0) {
211
+	    _LOG(trsp_socket::log_level_raw_msgs, 
212 212
 		 "vv M [|] u recvd msg via UDP vv\n--++--\n%.*s--++--\n",
213 213
 		 s_msg->len, s_msg->buf);
214 214
 	}