]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Add `session::consoleLog2()`
authorTravis Cross <tc@traviscross.com>
Wed, 16 Jul 2014 02:28:30 +0000 (02:28 +0000)
committerTravis Cross <tc@traviscross.com>
Wed, 16 Jul 2014 03:52:08 +0000 (03:52 +0000)
This allows emitting log messages that include the file name and line
number of the call.  Because we have the session object here, the log
messages can be correctly associated with the session from which they
were emitted.

As when the kernel developers need to 'fix' a system call, we'll just
add a number to the name of the existing function.

src/include/switch_cpp.h
src/switch_cpp.cpp

index 9ccb04d39e10ecdd4c5768805995f2c74f454c28..382c4b4fa17fb20fca11d79ef146291b2ff9adf9 100644 (file)
@@ -392,6 +392,7 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod
                 virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype) = 0;
 
                 SWITCH_DECLARE(void) consoleLog(char *level_str, char *msg);
+                SWITCH_DECLARE(void) consoleLog2(char *level_str, char *file, char *func, int line, char *msg);
         };
 
 
index 38481fd6357ec0099b4b222ba12fc0436e5cca66..e00f4d6280a8d6af7fb3ce9057494aa38e5e91ff 100644 (file)
@@ -1237,6 +1237,19 @@ SWITCH_DECLARE(void) CoreSession::consoleLog(char *level_str, char *msg)
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), level, "%s", switch_str_nil(msg));
 }
 
+SWITCH_DECLARE(void) CoreSession::consoleLog2(char *level_str, char *file, char *func, int line, char *msg)
+{
+       switch_log_level_t level = SWITCH_LOG_DEBUG;
+       if (level_str) {
+               level = switch_log_str2level(level_str);
+               if (level == SWITCH_LOG_INVALID) {
+                       level = SWITCH_LOG_DEBUG;
+               }
+       }
+    switch_log_printf(SWITCH_CHANNEL_ID_SESSION, file, func, line, (const char*)session,
+                                         level, "%s", switch_str_nil(msg));
+}
+
 /* ---- methods not bound to CoreSession instance ---- */