[Freeswitch-svn] [commit] r5790 - in freeswitch/trunk/src: . include include/private mod/applications/mod_commands

Freeswitch SVN anthm at freeswitch.org
Wed Oct 3 19:43:01 EDT 2007


Author: anthm
Date: Wed Oct  3 19:43:01 2007
New Revision: 5790

Modified:
   freeswitch/trunk/src/include/private/switch_core_pvt.h
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
   freeswitch/trunk/src/switch.c
   freeswitch/trunk/src/switch_console.c
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_log.c

Log:
add fsctl loglevel [<level>] fsctl command

Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h	Wed Oct  3 19:43:01 2007
@@ -156,6 +156,7 @@
 	switch_mutex_t *throttle_mutex;
 	uint32_t sps_total;
 	int32_t sps;
+	uint32_t hard_log_level;
 };
 
 extern struct switch_runtime runtime;

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Wed Oct  3 19:43:01 2007
@@ -1443,7 +1443,7 @@
   \param val the command arguement (if needed)
   \return 0 on success nonzero on error
 */
-SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t * val);
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t * val);
 
 /*!
   \brief Get the output console

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Wed Oct  3 19:43:01 2007
@@ -1007,7 +1007,8 @@
 	SCSC_PAUSE_INBOUND,
 	SCSC_HUPALL,
 	SCSC_SHUTDOWN,
-	SCSC_CHECK_RUNNING
+	SCSC_CHECK_RUNNING,
+	SCSC_LOGLEVEL
 } switch_session_ctl_t;
 
 typedef struct apr_pool_t switch_memory_pool_t;

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Wed Oct  3 19:43:01 2007
@@ -94,7 +94,7 @@
 {
 	int argc;
 	char *mydata, *argv[5];
-	uint32_t arg = 0;
+	int32_t arg = 0;
 
 	if (switch_strlen_zero(cmd)) {
 		stream->write_function(stream, "USAGE: %s\n", CTL_SYNTAX);
@@ -116,6 +116,18 @@
 		} else if (!strcasecmp(argv[0], "shutdown")) {
 			arg = 0;
 			switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
+		} else if (!strcasecmp(argv[0], "loglevel")) {
+			if (argc > 1) {
+				if (*argv[1] > 47 && *argv[1] < 58) {
+					arg = atoi(argv[1]);
+				} else {
+					arg = switch_log_str2level(argv[1]);
+				}
+			} else {
+				arg = -1;
+			}
+			switch_core_session_ctl(SCSC_LOGLEVEL, &arg);
+			stream->write_function(stream, "log level %s [%d]\n", switch_log_level2str(arg), arg);
 		} else {
 			stream->write_function(stream, "INVALID COMMAND\nUSAGE: fsctl [hupall|pause|resume|shutdown]\n");
 			goto end;

Modified: freeswitch/trunk/src/switch.c
==============================================================================
--- freeswitch/trunk/src/switch.c	(original)
+++ freeswitch/trunk/src/switch.c	Wed Oct  3 19:43:01 2007
@@ -68,7 +68,7 @@
  */
 static void handle_SIGHUP(int sig)
 {
-	uint32_t arg = 0;
+	int32_t arg = 0;
 	if (sig);
 	/* send shutdown signal to the freeswitch core */
 	switch_core_session_ctl(SCSC_SHUTDOWN, &arg);

Modified: freeswitch/trunk/src/switch_console.c
==============================================================================
--- freeswitch/trunk/src/switch_console.c	(original)
+++ freeswitch/trunk/src/switch_console.c	Wed Oct  3 19:43:01 2007
@@ -204,7 +204,7 @@
 	switch_memory_pool_t *pool = (switch_memory_pool_t *) obj;
 
 	while (running) {
-		uint32_t arg;
+		int32_t arg;
 
 		switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
 		if (!arg) {
@@ -270,7 +270,7 @@
 	switch_thread_create(&thread, thd_attr, console_thread, pool, pool);
 	
 	while (running) {
-		uint32_t arg = 0;
+		int32_t arg = 0;
 		switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
 		if (!arg) {
 			break;

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Wed Oct  3 19:43:01 2007
@@ -623,7 +623,7 @@
 	return switch_time_now() - runtime.initiated;
 }
 
-SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32_t * val)
+SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t * val)
 {
 	if (switch_test_flag((&runtime), SCF_SHUTTING_DOWN)) {
 		return -1;
@@ -646,6 +646,18 @@
 	case SCSC_CHECK_RUNNING:
 		*val = runtime.running;
 		break;
+	case SCSC_LOGLEVEL:
+		if (*val > -1) {
+			printf("WTF %d\n", *val);
+			runtime.hard_log_level = *val;
+		}
+
+		if (runtime.hard_log_level > SWITCH_LOG_CONSOLE) {
+			printf("WTF %d\n", *val);
+			runtime.hard_log_level = SWITCH_LOG_CONSOLE;
+		}
+		*val = runtime.hard_log_level;
+		break;
 	}
 
 	return 0;

Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c	(original)
+++ freeswitch/trunk/src/switch_log.c	Wed Oct  3 19:43:01 2007
@@ -30,7 +30,8 @@
  *
  */
 #include <switch.h>
-
+#include "private/switch_core_pvt.h"
+struct switch_runtime runtime;
 
 static const char *LEVELS[] = {
 	"EMERG",
@@ -166,6 +167,10 @@
 	uint32_t len;
 	const char *extra_fmt = "%s [%s] %s:%d %s()%c%s";
 
+	if (level < runtime.hard_log_level) {
+		return;
+	}
+
 	va_start(ap, fmt);
 
 	handle = switch_core_data_channel(channel);



More information about the Freeswitch-svn mailing list