add fsctl loglevel [<level>] fsctl command
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5790 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e44ad9588c
commit
1667112b3b
|
@ -156,6 +156,7 @@ struct switch_runtime {
|
|||
switch_mutex_t *throttle_mutex;
|
||||
uint32_t sps_total;
|
||||
int32_t sps;
|
||||
uint32_t hard_log_level;
|
||||
};
|
||||
|
||||
extern struct switch_runtime runtime;
|
||||
|
|
|
@ -1443,7 +1443,7 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void);
|
|||
\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
|
||||
|
|
|
@ -1007,7 +1007,8 @@ typedef enum {
|
|||
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;
|
||||
|
|
|
@ -94,7 +94,7 @@ SWITCH_STANDARD_API(ctl_function)
|
|||
{
|
||||
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 @@ SWITCH_STANDARD_API(ctl_function)
|
|||
} 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;
|
||||
|
|
|
@ -68,7 +68,7 @@ static HANDLE shutdown_event;
|
|||
*/
|
||||
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);
|
||||
|
|
|
@ -204,7 +204,7 @@ static void *SWITCH_THREAD_FUNC console_thread(switch_thread_t *thread, void *ob
|
|||
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_DECLARE(void) switch_console_loop(void)
|
|||
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;
|
||||
|
|
|
@ -623,7 +623,7 @@ SWITCH_DECLARE(switch_time_t) switch_core_uptime(void)
|
|||
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 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, uint32
|
|||
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;
|
||||
|
|
|
@ -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 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue