speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/5] server - Send log level configuration setting to speech modu


From: Luke Yelavich
Subject: [PATCH 1/5] server - Send log level configuration setting to speech modules
Date: Tue, 23 Jun 2009 16:54:36 +1000

From: Luke Yelavich <address@hidden>
To: address@hidden

Send the log level configuration setting through to the speech modules as a
mandetory parameter, as logging is not yet configurable for speech modules,
causing undesirable log file sizes in most cases.
---
 ChangeLog           |   17 +++++++++++++++++
 intl/fdset.h        |    1 +
 src/server/config.c |   15 ++++++++++++++-
 src/server/module.c |   11 +++++++++++
 src/server/output.c |   19 +++++++++++++++++++
 src/server/output.h |    1 +
 6 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 66cc64d..2f2af09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-06-23  Luke Yelavich <luke.yelavich at canonical.com>
+
+       * src/server/config.c: Add new macro GLOBAL_SET_LOGLEVEL, to set the
+       log level for both the server and speech modules. Make use of this
+       macro when reading the LogLevel setting from the configuration file.
+
+       * src/server/output.c (output_send_loglevel_setting): Fix typo.
+
+2009-06-22  Luke Yelavich <luke.yelavich at canonical.com>
+
+       * src/server/output.c: Add output_send_loglevel_setting function
+       to send the loglevel configuration setting through to speech modules.
+
+       * src/server/module.c (load_output_module): Add a call to
+       output_send_loglevel_setting to send the log level configuration
+       setting to modules.
+
 2009-05-14  Hynek Hanke  <hanke at brailcom.org>
 
        * src/audio/pulse.c (_pulse_open): Typo.
diff --git a/intl/fdset.h b/intl/fdset.h
index 100211f..420efe0 100644
--- a/intl/fdset.h
+++ b/intl/fdset.h
@@ -132,6 +132,7 @@ typedef struct{
     int audio_pulse_target_length;
     int audio_pulse_pre_buffering;
     int audio_pulse_min_request;
+    int log_level;
 
     /* TODO: Should be moved out */
     unsigned int hist_cur_uid;
diff --git a/src/server/config.c b/src/server/config.c
index 4cf38b5..f47af0d 100644
--- a/src/server/config.c
+++ b/src/server/config.c
@@ -153,6 +153,19 @@ free_config_options(configoption_t *opts, int *num)
        return NULL; \
    }    
 
+#define GLOBAL_SET_LOGLEVEL(name, arg, cond, str) \
+   DOTCONF_CB(cb_ ## name) \
+   { \
+       int val = cmd->data.value; \
+       if (cl_spec_section) \
+         FATAL("This command isn't allowed in a client specific section!"); \
+       if (!(cond)) FATAL(str); \
+       if (!SpeechdOptions.arg ## _set){ \
+         SpeechdOptions.arg = val; \
+         GlobalFDSet.arg = val; \
+       } \
+       return NULL; \
+   }
 
 /* == CALLBACK DEFINITIONS == */
 GLOBAL_FDSET_OPTION_CB_STR(DefaultModule, output_module);
@@ -183,7 +196,7 @@ GLOBAL_FDSET_OPTION_CB_SPECIAL(DefaultCapLetRecognition, 
cap_let_recogn, ECapLet
 
 SPEECHD_OPTION_CB_INT_M(LocalhostAccessOnly, localhost_access_only, val>=0, 
"Invalid access controll mode!");
 SPEECHD_OPTION_CB_INT_M(Port, port, val>=0, "Invalid port number!");
-SPEECHD_OPTION_CB_INT_M(LogLevel, log_level, (val>=0)&&(val<=5), "Invalid log 
(verbosity) level!");
+GLOBAL_SET_LOGLEVEL(LogLevel, log_level, (val>=0)&&(val<=5), "Invalid log 
(verbosity) level!");
 SPEECHD_OPTION_CB_INT(MaxHistoryMessages, max_history_messages, val>=0, 
"Invalid parameter!");
 
 DOTCONF_CB(cb_LanguageDefaultModule)
diff --git a/src/server/module.c b/src/server/module.c
index 2cc365d..fd16f5c 100644
--- a/src/server/module.c
+++ b/src/server/module.c
@@ -208,6 +208,17 @@ load_output_module(char* mod_name, char* mod_prog, char* 
mod_cfgfile, char* mod_
              return NULL;
            }
 
+           /* Send log level configuration setting */
+           ret = output_send_loglevel_setting(module);
+           if (ret !=0){
+             MSG(1, "ERROR: Can't set the log level inin the output module.");
+             module->working = 0;
+             kill(module->pid, 9);
+             waitpid(module->pid, NULL, WNOHANG);
+             destroy_module(module);
+             return NULL;
+           }
+
            /* Get a list of supported voices */
            _output_get_voices(module);
            fclose(f);
diff --git a/src/server/output.c b/src/server/output.c
index 0a58eee..a31b709 100644
--- a/src/server/output.c
+++ b/src/server/output.c
@@ -400,6 +400,25 @@ output_send_audio_settings(OutputModule *output)
 
     return 0;
 }
+
+int
+output_send_loglevel_setting(OutputModule *output)
+{
+    GString *set_str;
+    int err;
+
+    MSG(4, "Module set parameters.");
+    set_str = g_string_new("");
+    ADD_SET_INT(log_level);
+
+    SEND_CMD_N("LOGLEVEL");
+    SEND_DATA_N(set_str->str);
+    SEND_CMD_N(".");
+
+    g_string_free(set_str, 1);
+
+    return 0;
+}
 #undef ADD_SET_INT
 #undef ADD_SET_STR
 
diff --git a/src/server/output.h b/src/server/output.h
index bbcec7c..d6d73f3 100644
--- a/src/server/output.h
+++ b/src/server/output.h
@@ -43,6 +43,7 @@ char* output_read_reply2(OutputModule *output);
 int output_send_data(char* cmd, OutputModule *output, int wfr);
 int output_send_settings(TSpeechDMessage *msg, OutputModule *output);
 int output_send_audio_settings(OutputModule *output);
+int output_send_loglevel_setting(OutputModule *output);
 int output_module_is_speaking(OutputModule *output, char **index_mark);
 int waitpid_with_timeout(pid_t pid, int *status_ptr, int options, size_t 
timeout);
 int output_close(OutputModule *module);
-- 
1.6.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]