mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-31 07:34:19 +00:00
Gut Logger and put it back modular style
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1117 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
628e59a3ae
commit
559b8ab26c
47 files changed
+1313
-913
No files matched your search
@@ -105,7 +105,7 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
||||
perl_destruct(globals.my_perl);
|
||||
perl_free(globals.my_perl);
|
||||
globals.my_perl = NULL;
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Unallocated perl interpreter.\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unallocated perl interpreter.\n");
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -117,11 +117,11 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_modul
|
||||
char code[1024];
|
||||
|
||||
if (!(my_perl = perl_alloc())) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate perl intrepreter\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not allocate perl intrepreter\n");
|
||||
switch_core_destroy();
|
||||
return SWITCH_STATUS_MEMERR;
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Allocated perl intrepreter.\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated perl intrepreter.\n");
|
||||
|
||||
PERL_SET_CONTEXT(my_perl);
|
||||
perl_construct(my_perl);
|
||||
|
||||
@@ -56,12 +56,12 @@ int fs_console_loop(void)
|
||||
|
||||
void fs_console_log(char *msg)
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, msg);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
|
||||
}
|
||||
|
||||
void fs_console_clean(char *msg)
|
||||
{
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, msg);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
|
||||
}
|
||||
|
||||
struct switch_core_session *fs_core_session_locate(char *uuid)
|
||||
|
||||
@@ -152,7 +152,7 @@ struct db_obj {
|
||||
static void js_error(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
if (message) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s\n", message);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -765,7 +765,7 @@ static JSBool js_fetchurl_hash(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
curl_easy_perform(curl_handle);
|
||||
curl_easy_cleanup(curl_handle);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error!\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -803,10 +803,10 @@ static JSBool js_fetchurl_file(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
curl_easy_cleanup(curl_handle);
|
||||
close(config_data.fd);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error!\n");
|
||||
}
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error!\n");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
@@ -1012,7 +1012,7 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
}
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OH OH no pool\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -1028,10 +1028,10 @@ static JSBool session_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
switch_set_flag(jss, S_HUP);
|
||||
return JS_TRUE;
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Create Channel\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Create Channel\n");
|
||||
}
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Missing Args\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Missing Args\n");
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
@@ -1091,7 +1091,7 @@ static JSBool fileio_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
||||
}
|
||||
switch_core_new_memory_pool(&pool);
|
||||
if (switch_file_open(&fd, path, flags, SWITCH_FPROT_UREAD|SWITCH_FPROT_UWRITE, pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Open File!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Open File!\n");
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
return JS_FALSE;
|
||||
}
|
||||
@@ -1240,7 +1240,7 @@ static JSBool db_construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
||||
char *dbname = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
|
||||
switch_core_new_memory_pool(&pool);
|
||||
if (! (db = switch_core_db_open_file(dbname))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Open DB!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Open DB!\n");
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
return JS_FALSE;
|
||||
}
|
||||
@@ -1318,7 +1318,7 @@ static JSBool db_exec(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
||||
|
||||
switch_core_db_exec(dbo->db, sql, cb_func, arg, &err);
|
||||
if (err) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error %s\n", err);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error %s\n", err);
|
||||
switch_core_db_free(err);
|
||||
*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
|
||||
}
|
||||
@@ -1396,7 +1396,7 @@ static JSBool db_prepare(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
char *sql = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
|
||||
|
||||
if(switch_core_db_prepare(dbo->db, sql, 0, &dbo->stmt, 0)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Error %s\n", switch_core_db_errmsg(dbo->db));
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error %s\n", switch_core_db_errmsg(dbo->db));
|
||||
} else {
|
||||
*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
|
||||
}
|
||||
@@ -1469,15 +1469,15 @@ static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
if (argc > 0) {
|
||||
if (JS_ValueToObject(cx, argv[0], &session_obj)) {
|
||||
if (!(jss = JS_GetPrivate(cx, session_obj))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Session [1]\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Find Session [1]\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Session [2]\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Find Session [2]\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Missing Session Arg\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Missing Session Arg\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (argc > 1) {
|
||||
@@ -1486,14 +1486,14 @@ static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
|
||||
if (argc > 2) {
|
||||
if (!JS_ValueToInt32(cx, argv[2], &memory)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Convert to INT\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Convert to INT\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
switch_core_new_memory_pool(&pool);
|
||||
|
||||
if (!(tto = switch_core_alloc(pool, sizeof(*tto)))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Memory Error\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Memory Error\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -1506,9 +1506,9 @@ static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
read_codec->implementation->number_of_channels,
|
||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||
NULL, pool) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activated\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Raw Codec Activation Failed\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -1520,9 +1520,9 @@ static JSBool teletone_construct(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
(read_codec->implementation->samples_per_second / 50) * read_codec->implementation->number_of_channels,
|
||||
pool) == SWITCH_STATUS_SUCCESS) {
|
||||
tto->timer = &tto->timer_base;
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Timer INIT Success %u\n", ms);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timer INIT Success %u\n", ms);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Timer INIT Failed\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timer INIT Failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1602,7 +1602,7 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
|
||||
if (argc > 1) {
|
||||
if (!JS_ValueToInt32(cx, argv[1], &loops)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Convert to INT\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Convert to INT\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
loops--;
|
||||
@@ -1686,7 +1686,7 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval
|
||||
write_frame.samples = write_frame.datalen / 2;
|
||||
for (stream_id = 0; stream_id < switch_core_session_get_stream_count(session); stream_id++) {
|
||||
if (switch_core_session_write_frame(session, &write_frame, -1, stream_id) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bad Write\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Bad Write\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1744,7 +1744,7 @@ static JSBool js_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
|
||||
char *msg;
|
||||
|
||||
if ((msg = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "JS_LOG: %s", msg);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "JS_LOG: %s", msg);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -1758,7 +1758,7 @@ static JSBool js_include(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
eval_some_js(code, cx, obj, rval);
|
||||
return JS_TRUE;
|
||||
}
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid Arguements\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid Arguements\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -1801,13 +1801,13 @@ static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
if (argc > 1) {
|
||||
if (JS_ValueToObject(cx, argv[0], &session_obj_a)) {
|
||||
if (!(jss_a = JS_GetPrivate(cx, session_obj_a))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Session [1]\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Find Session [1]\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
if (JS_ValueToObject(cx, argv[1], &session_obj_b)) {
|
||||
if (!(jss_b = JS_GetPrivate(cx, session_obj_b))) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Find Session [1]\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Find Session [1]\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1815,12 +1815,12 @@ static JSBool js_bridge(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
||||
|
||||
if (argc > 3) {
|
||||
if (!JS_ValueToInt32(cx, argv[3], &timelimit)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Cannot Convert to INT\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot Convert to INT\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
if (!(jss_a && jss_b)) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failure! %s %s\n", jss_a ? "y" : "n", jss_b ? "y" : "n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@@ -1938,9 +1938,9 @@ static JSBool js_email(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
||||
|
||||
|
||||
if (file) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Emailed file [%s] to [%s]\n", filename, to);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed file [%s] to [%s]\n", filename, to);
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Emailed data to [%s]\n", to);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Emailed data to [%s]\n", to);
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -2072,7 +2072,7 @@ static void js_parse_and_execute(switch_core_session *session, char *input_code)
|
||||
JS_SetPrivate(cx, javascript_global_object, session);
|
||||
}
|
||||
} else {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Allocation Error!\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocation Error!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2128,7 +2128,7 @@ static void js_thread_launch(char *text)
|
||||
|
||||
if (!module_pool) {
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "OH OH no pool\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2191,8 +2191,6 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_modul
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*interface = &spidermonkey_module_interface;
|
||||
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hello World!\n");
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
Reference in new issue
Block a user