Commit 2e6eba61 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Improvement for manage logs


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@395 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent af2a4790
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp_log.h,v 1.7 2007-09-30 20:35:08 mtheo Exp $
* $Id: nmxp_log.h,v 1.8 2007-10-01 05:44:04 mtheo Exp $
*
*/
......@@ -42,6 +42,11 @@ const char *nmxp_log_version();
void nmxp_log_init(int (*func_log)(char *), int (*func_log_err)(char *));
/*! \brief TODO
*/
void nmxp_log_add(int (*func_log)(char *), int (*func_log_err)(char *));
/*! \brief TODO
*/
int nmxp_log_stdout(char *msg);
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp_log.c,v 1.9 2007-09-30 20:35:08 mtheo Exp $
* $Id: nmxp_log.c,v 1.10 2007-10-01 05:44:04 mtheo Exp $
*
*/
......@@ -55,8 +55,17 @@ int (*p_func_log_err[NMXP_MAX_FUNC_LOG]) (char *);
void nmxp_log_init(int (*func_log)(char *), int (*func_log_err)(char *)) {
n_func_log = 0;
n_func_log_err = 0;
p_func_log[n_func_log++] = (func_log == NULL)? func_log : nmxp_log_stdout;
p_func_log_err[n_func_log_err++] = (func_log_err == NULL)? func_log_err : nmxp_log_stdout;
nmxp_log_add(func_log, func_log_err);
}
void nmxp_log_add(int (*func_log)(char *), int (*func_log_err)(char *)) {
if(func_log == NULL) {
p_func_log[n_func_log++] = func_log;
}
if(func_log_err == NULL) {
p_func_log_err[n_func_log_err++] = nmxp_log_stdout;
}
}
......@@ -77,6 +86,7 @@ int nmxp_log(int level, int verb, ... )
char *format;
va_list listptr;
time_t loc_time;
int i;
va_start(listptr, verb);
format = va_arg(listptr, char *);
......@@ -94,7 +104,9 @@ int nmxp_log(int level, int verb, ... )
//TOREMOVE printf("%s - %s: error: %s", timestr, PACKAGE_NAME, message);
sprintf(message_final, "%s - %s: error: %s", timestr, PACKAGE_NAME, message);
if(n_func_log_err > 0) {
p_func_log_err[0](message_final);
for(i=0; i < n_func_log_err; i++) {
p_func_log_err[i](message_final);
}
} else {
nmxp_log_stdout(message_final);
}
......@@ -103,7 +115,9 @@ int nmxp_log(int level, int verb, ... )
//TOREMOVE printf("%s - %s: warning: %s", timestr, PACKAGE_NAME, message);
sprintf(message_final, "%s - %s: warning: %s", timestr, PACKAGE_NAME, message);
if(n_func_log > 0) {
p_func_log[0](message_final);
for(i=0; i < n_func_log; i++) {
p_func_log[i](message_final);
}
} else {
nmxp_log_stdout(message_final);
}
......@@ -112,7 +126,9 @@ int nmxp_log(int level, int verb, ... )
//TOREMOVE printf("%s", message);
sprintf(message_final, "%s", message);
if(n_func_log > 0) {
p_func_log[0](message_final);
for(i=0; i < n_func_log; i++) {
p_func_log[i](message_final);
}
} else {
nmxp_log_stdout(message_final);
}
......@@ -121,7 +137,9 @@ int nmxp_log(int level, int verb, ... )
//TOREMOVE printf("%s: %s", PACKAGE_NAME, message);
sprintf(message_final, "%s: %s", PACKAGE_NAME, message);
if(n_func_log > 0) {
p_func_log[0](message_final);
for(i=0; i < n_func_log; i++) {
p_func_log[i](message_final);
}
} else {
nmxp_log_stdout(message_final);
}
......@@ -130,7 +148,9 @@ int nmxp_log(int level, int verb, ... )
//TOREMOVE printf("%s - %s: %s", timestr, PACKAGE_NAME, message);
sprintf(message_final, "%s - %s: %s", timestr, PACKAGE_NAME, message);
if(n_func_log > 0) {
p_func_log[0](message_final);
for(i=0; i < n_func_log; i++) {
p_func_log[i](message_final);
}
} else {
nmxp_log_stdout(message_final);
}
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool.c,v 1.77 2007-09-29 10:08:19 mtheo Exp $
* $Id: nmxptool.c,v 1.78 2007-10-01 05:44:04 mtheo Exp $
*
*/
......@@ -142,6 +142,7 @@ int main (int argc, char **argv) {
if(nmxptool_check_params(&params) != 0) {
return 1;
}
nmxp_log_init(nmxptool_ew_logit_msg, nmxptool_ew_logit_err);
#endif
} else {
......
......@@ -614,12 +614,14 @@ void nmxptool_ew_send_heartbeat_if_needed() {
*
* Hooks for Earthworm logging facility.
***************************************************************************/
void nmxptool_ew_logit_msg (const char *msg) {
logit ("t", (char *) msg);
int nmxptool_ew_logit_msg (char *msg) {
logit ("t", msg);
return 0;
}
void nmxptool_ew_logit_err (const char *msg) {
logit ("et", (char *) msg);
int nmxptool_ew_logit_err (char *msg) {
logit ("et", msg);
return 0;
}
......
......@@ -38,8 +38,8 @@ void nmxptool_ew_report_status ( MSG_LOGO *pLogo, short code, char * message );
int nmxptool_ew_check_flag_terminate();
void nmxptool_ew_send_heartbeat_if_needed();
void nmxptool_ew_logit_msg ( const char *msg );
void nmxptool_ew_logit_err ( const char *msg );
int nmxptool_ew_logit_msg ( char *msg );
int nmxptool_ew_logit_err ( char *msg );
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment