have LOGF macros add a newline, so user code doesn't need to.
This commit is contained in:
@@ -305,9 +305,9 @@ void uc_logf(int log_level, int module, int raw,
|
|||||||
// to override that by defining UC_DEBUG_ALWAYS
|
// to override that by defining UC_DEBUG_ALWAYS
|
||||||
#if defined(DEBUG) || defined(UC_DEBUG_ALWAYS)
|
#if defined(DEBUG) || defined(UC_DEBUG_ALWAYS)
|
||||||
# define UC_DEBUGF(mod, fmt, ...)\
|
# define UC_DEBUGF(mod, fmt, ...)\
|
||||||
uc_logf(UC_LL_DEBUG, mod,0 , UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
|
uc_logf(UC_LL_DEBUG, mod,0 , UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__)
|
||||||
# define UC_DEBUGFR(mod, fmt, ...)\
|
# define UC_DEBUGFR(mod, fmt, ...)\
|
||||||
uc_logf(UC_LL_DEBUG, mod,1 , UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
|
uc_logf(UC_LL_DEBUG, mod,1 , UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
# define UC_DEBUGF(mod, fmt, ...) do {} while (0)
|
# define UC_DEBUGF(mod, fmt, ...) do {} while (0)
|
||||||
# define UC_DEBUGFR(mod, fmt, ...) do {} while (0)
|
# define UC_DEBUGFR(mod, fmt, ...) do {} while (0)
|
||||||
@@ -317,6 +317,7 @@ void uc_logf(int log_level, int module, int raw,
|
|||||||
*
|
*
|
||||||
* For log messages with UC_LL_DEBUG, the UC_DEBUGF() macro can be used,
|
* For log messages with UC_LL_DEBUG, the UC_DEBUGF() macro can be used,
|
||||||
* UC_DEBUGF will only be compiled in if the DEBUG macro is defined
|
* UC_DEBUGF will only be compiled in if the DEBUG macro is defined
|
||||||
|
* fmt must be a string literal, and a newline will be added
|
||||||
*
|
*
|
||||||
* @param lvl log level of this log message
|
* @param lvl log level of this log message
|
||||||
* @param mod module id of this log messagex.
|
* @param mod module id of this log messagex.
|
||||||
@@ -324,11 +325,11 @@ void uc_logf(int log_level, int module, int raw,
|
|||||||
* @param ... printf style arguments
|
* @param ... printf style arguments
|
||||||
*/
|
*/
|
||||||
#define UC_LOGF(lvl, mod, fmt, ...) \
|
#define UC_LOGF(lvl, mod, fmt, ...) \
|
||||||
uc_logf(lvl, mod, 0, UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
|
uc_logf(lvl, mod, 0, UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
/** Raw logging ,Like UC_LOGF, but only prints the supplied
|
/** Raw logging ,Like UC_LOGF, but only prints the supplied
|
||||||
* data, not timestamp, log level etc.
|
* data, not timestamp, log level, newline, etc.
|
||||||
*/
|
*/
|
||||||
#define UC_LOGFR(lvl, mod, fmt, ...) \
|
#define UC_LOGFR(lvl, mod, fmt, ...) \
|
||||||
uc_logf(lvl, mod, 1, UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
|
uc_logf(lvl, mod, 1, UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
|
||||||
|
|||||||
+12
-12
@@ -49,27 +49,27 @@ int main(int argc, char *argv[])
|
|||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
dest = uc_log_new_stderr(UC_LL_INFO, 0);
|
dest = uc_log_new_stderr(UC_LL_INFO, 0);
|
||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 2);
|
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 2);
|
||||||
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 3);
|
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 3);
|
||||||
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 4);
|
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 4);
|
||||||
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 5);
|
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d", 5);
|
||||||
UC_LOGF( UC_LL_WARNING, HO, "Test HO warning%d\n", 2);
|
UC_LOGF( UC_LL_WARNING, HO, "Test HO warning%d", 2);
|
||||||
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN info \n" );
|
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN info " );
|
||||||
UC_LOGF( UC_LL_WARNING, MAIN, "Test MAIN warning\n" );
|
UC_LOGF( UC_LL_WARNING, MAIN, "Test MAIN warning" );
|
||||||
|
|
||||||
uc_log_destination_set_module_loglevel(dest, MAIN, UC_LL_INFO);
|
uc_log_destination_set_module_loglevel(dest, MAIN, UC_LL_INFO);
|
||||||
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 2\n" );
|
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 2" );
|
||||||
|
|
||||||
UC_LOGFR(UC_LL_INFO, MAIN, "Test RAW logging 1\n" );
|
UC_LOGFR(UC_LL_INFO, MAIN, "Test RAW logging 1" );
|
||||||
|
|
||||||
uc_log_destination_set_module_loglevel(dest,MAIN, UC_LL_WARNING);
|
uc_log_destination_set_module_loglevel(dest,MAIN, UC_LL_WARNING);
|
||||||
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 3\n" );
|
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 3" );
|
||||||
|
|
||||||
uc_log_destination_set_loglevel(dest, UC_LL_DEBUG);
|
uc_log_destination_set_loglevel(dest, UC_LL_DEBUG);
|
||||||
UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD NOT SHOW\n" );
|
UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD NOT SHOW" );
|
||||||
//uc_log_destination_set_module_loglevel(dest, MAIN, UC_LL_INFO);
|
//uc_log_destination_set_module_loglevel(dest, MAIN, UC_LL_INFO);
|
||||||
uc_log_destination_set_mask(dest, "HO=ERROR:MAIN=DEBUG:HO=DEBUG");
|
uc_log_destination_set_mask(dest, "HO=ERROR:MAIN=DEBUG:HO=DEBUG");
|
||||||
UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD SHOW\n" );
|
UC_LOGF( UC_LL_DEBUG, MAIN, "Test MAIN DEBUG SHOULD SHOW" );
|
||||||
|
|
||||||
uc_log_delete_destination(dest);
|
uc_log_delete_destination(dest);
|
||||||
|
|
||||||
|
|||||||
+70
-70
@@ -53,15 +53,15 @@ START_TEST (test_logfile_location)
|
|||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
uc_log_add_destination(dest); //adding this twice should do nothing
|
uc_log_add_destination(dest); //adding this twice should do nothing
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n");
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2");
|
||||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n");
|
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3");
|
||||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n");
|
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4");
|
||||||
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n");
|
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5");
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_logfile_delete_destination)
|
START_TEST (test_logfile_delete_destination)
|
||||||
@@ -87,28 +87,28 @@ START_TEST (test_logfile_delete_destination)
|
|||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
uc_log_add_destination(dest); //adding this twice should do nothing
|
uc_log_add_destination(dest); //adding this twice should do nothing
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n");
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2");
|
||||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n");
|
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3");
|
||||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n");
|
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4");
|
||||||
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n");
|
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5");
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
|
||||||
|
|
||||||
uc_log_delete_destination(dest);
|
uc_log_delete_destination(dest);
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n");
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2");
|
||||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n");
|
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3");
|
||||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n");
|
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4");
|
||||||
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n");
|
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5");
|
||||||
|
|
||||||
//since we deleted destinatiion, no more logging should appear in the file
|
//since we deleted destinatiion, no more logging should appear in the file
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
|
||||||
|
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@@ -134,12 +134,12 @@ START_TEST (test_logfile_no_location)
|
|||||||
fail_if(dest == NULL);
|
fail_if(dest == NULL);
|
||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 52*2, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 52*2, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_logfile_loglevel_surpressed_dest)
|
START_TEST (test_logfile_loglevel_surpressed_dest)
|
||||||
@@ -169,9 +169,9 @@ START_TEST (test_logfile_loglevel_surpressed_dest)
|
|||||||
UC_LOGF(UC_LL_INFO, 1, "Lorum ipson %d", 1);
|
UC_LOGF(UC_LL_INFO, 1, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
|
|
||||||
fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_logfile_loglevel_surpressed_module)
|
START_TEST (test_logfile_loglevel_surpressed_module)
|
||||||
@@ -201,9 +201,9 @@ START_TEST (test_logfile_loglevel_surpressed_module)
|
|||||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 100);
|
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 100);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
|
|
||||||
fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_logfile_reopen_files)
|
START_TEST (test_logfile_reopen_files)
|
||||||
@@ -228,24 +228,24 @@ START_TEST (test_logfile_reopen_files)
|
|||||||
fail_if(dest == NULL);
|
fail_if(dest == NULL);
|
||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);
|
||||||
|
|
||||||
rc = remove(FILE_NAME);
|
rc = remove(FILE_NAME);
|
||||||
fail_if(rc != 0, "Remove failed %s\n", strerror(errno));
|
fail_if(rc != 0, "Remove failed %s", strerror(errno));
|
||||||
|
|
||||||
rc = uc_log_reopen_files();
|
rc = uc_log_reopen_files();
|
||||||
fail_if(rc != 0, "uc_log_reopen_files failed: %d\n", rc);
|
fail_if(rc != 0, "uc_log_reopen_files failed: %d", rc);
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "2. stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 77, "was %ld\n", (long)st.st_size);//should only one line there now
|
fail_if(st.st_size != 77, "was %ld", (long)st.st_size);//should only one line there now
|
||||||
|
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@@ -277,29 +277,29 @@ START_TEST (test_logfile_remove_dest)
|
|||||||
uc_log_add_destination(dest1);
|
uc_log_add_destination(dest1);
|
||||||
uc_log_add_destination(dest2);
|
uc_log_add_destination(dest2);
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);
|
||||||
|
|
||||||
uc_log_remove_destination(dest1);
|
uc_log_remove_destination(dest1);
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); //should not be logged now
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1); //should not be logged now
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "2. stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size);//should be same size
|
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);//should be same size
|
||||||
|
|
||||||
//removing the last destination should be fine too
|
//removing the last destination should be fine too
|
||||||
uc_log_remove_destination(dest2);
|
uc_log_remove_destination(dest2);
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "2. stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 77*2, "was %ld\n", (long)st.st_size);//should be same size
|
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);//should be same size
|
||||||
|
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@@ -326,9 +326,9 @@ START_TEST (test_logfile_full_filesystem)
|
|||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
|
|
||||||
for (i = 0; i < 1024; i++) {
|
for (i = 0; i < 1024; i++) {
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
END_TEST
|
END_TEST
|
||||||
@@ -370,7 +370,7 @@ START_TEST (test_logfile_invalid_file_after_reopen)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
uc_log_init(&mods);
|
uc_log_init(&mods);
|
||||||
printf("SUBDIR_FILE_NAME= " SUBDIR_FILE_NAME " \n");
|
printf("SUBDIR_FILE_NAME= " SUBDIR_FILE_NAME " ");
|
||||||
|
|
||||||
dest = uc_log_new_file(SUBDIR_FILE_NAME, UC_LL_DEBUG, 1);
|
dest = uc_log_new_file(SUBDIR_FILE_NAME, UC_LL_DEBUG, 1);
|
||||||
fail_if(dest == NULL);
|
fail_if(dest == NULL);
|
||||||
@@ -378,18 +378,18 @@ START_TEST (test_logfile_invalid_file_after_reopen)
|
|||||||
logging_rm_subdir();
|
logging_rm_subdir();
|
||||||
|
|
||||||
rc = access(SUBDIR_FILE_NAME, W_OK);
|
rc = access(SUBDIR_FILE_NAME, W_OK);
|
||||||
fail_if(rc == 0, "Test setup is wrong. Can still access" SUBDIR_FILE_NAME "\n");
|
fail_if(rc == 0, "Test setup is wrong. Can still access" SUBDIR_FILE_NAME "");
|
||||||
|
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
uc_log_reopen_files();
|
uc_log_reopen_files();
|
||||||
|
|
||||||
//this should not crash now.
|
//this should not crash now.
|
||||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson %d", 1);
|
||||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d\n", 1);
|
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@@ -419,8 +419,8 @@ START_TEST (test_logfile_raw)
|
|||||||
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 14*2, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 14*2, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_logfile_dest_mask)
|
START_TEST (test_logfile_dest_mask)
|
||||||
@@ -454,19 +454,19 @@ START_TEST (test_logfile_dest_mask)
|
|||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
|
|
||||||
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
||||||
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
|
||||||
|
|
||||||
uc_log_destination_set_mask(dest, "MOD1=DEBUG:mod2=Debug");
|
uc_log_destination_set_mask(dest, "MOD1=DEBUG:mod2=Debug");
|
||||||
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
||||||
UC_LOGFR(UC_LL_DEBUG, 1, "Lorum ipson %d\n", 1);
|
UC_LOGFR(UC_LL_DEBUG, 1, "Lorum ipson %d\n", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 14*2, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 14*2, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_loglevel_module_none)
|
START_TEST (test_loglevel_module_none)
|
||||||
@@ -494,8 +494,8 @@ START_TEST (test_loglevel_module_none)
|
|||||||
UC_LOGFR(UC_LL_ERROR, 0, "Lorum ipson %d\n", 1);
|
UC_LOGFR(UC_LL_ERROR, 0, "Lorum ipson %d\n", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
START_TEST (test_loglevel_dest_none)
|
START_TEST (test_loglevel_dest_none)
|
||||||
@@ -523,8 +523,8 @@ START_TEST (test_loglevel_dest_none)
|
|||||||
UC_LOGFR(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1);
|
UC_LOGFR(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1);
|
||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size);
|
fail_if(st.st_size != 0, "was %ld", (long)st.st_size);
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ void peer_add_addr(struct HBContext *ctx, const struct sockaddr_in *addr)
|
|||||||
int usec;
|
int usec;
|
||||||
|
|
||||||
if (peer != NULL) {
|
if (peer != NULL) {
|
||||||
UC_LOGF(UC_LL_INFO, LMAIN, "Ignoring adding existing peer %s:%u\n",
|
UC_LOGF(UC_LL_INFO, LMAIN, "Ignoring adding existing peer %s:%u",
|
||||||
inet_ntoa(addr->sin_addr), addr->sin_port);
|
inet_ntoa(addr->sin_addr), addr->sin_port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -169,12 +169,12 @@ void peer_do_state(struct HBPeer *peer, enum PeerEvent event)
|
|||||||
{
|
{
|
||||||
if (peer->state == PeerUnknown || peer->state == PeerDead) {
|
if (peer->state == PeerUnknown || peer->state == PeerDead) {
|
||||||
if (event == PeerReceived) {
|
if (event == PeerReceived) {
|
||||||
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is now alive\n");
|
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is now alive");
|
||||||
peer->state = PeerAlive;
|
peer->state = PeerAlive;
|
||||||
}
|
}
|
||||||
} else if (peer->state == PeerAlive) {
|
} else if (peer->state == PeerAlive) {
|
||||||
if (event == PeerTimedout) {
|
if (event == PeerTimedout) {
|
||||||
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is dead !\n");
|
UC_LOGF(UC_LL_INFO, LMAIN, "Peer is dead !");
|
||||||
peer->state = PeerDead;
|
peer->state = PeerDead;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,7 +206,7 @@ void hb_read(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UC_LOGF(UC_LL_INFO, LMAIN, "Message from %s:%u\n", inet_ntoa(peer_addr.sin_addr),
|
UC_LOGF(UC_LL_INFO, LMAIN, "Message from %s:%u", inet_ntoa(peer_addr.sin_addr),
|
||||||
ntohs(peer_addr.sin_port));
|
ntohs(peer_addr.sin_port));
|
||||||
|
|
||||||
if (rc < 4) {
|
if (rc < 4) {
|
||||||
@@ -216,13 +216,13 @@ void hb_read(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
|
|||||||
|
|
||||||
magic = uc_unpack_32_be(buf);
|
magic = uc_unpack_32_be(buf);
|
||||||
if (magic != HB_MAGIX) {
|
if (magic != HB_MAGIX) {
|
||||||
UC_LOGF(UC_LL_WARNING, LMAIN, "Received unknown message, magic = 0x%X\n", magic);
|
UC_LOGF(UC_LL_WARNING, LMAIN, "Received unknown message, magic = 0x%X", magic);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer = hb_peer_find(ctx, &peer_addr);
|
peer = hb_peer_find(ctx, &peer_addr);
|
||||||
if (peer == NULL) {
|
if (peer == NULL) {
|
||||||
UC_LOGF(UC_LL_WARNING, LMAIN, "Found no peer\n");
|
UC_LOGF(UC_LL_WARNING, LMAIN, "Found no peer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,13 +241,13 @@ void init_hb_context(struct HBContext *ctx, uint16_t local_port)
|
|||||||
|
|
||||||
sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if (sock_fd == -1) {
|
if (sock_fd == -1) {
|
||||||
UC_LOGF(UC_LL_ERROR, LMAIN, "socket failed : %s\n", strerror(errno));
|
UC_LOGF(UC_LL_ERROR, LMAIN, "socket failed : %s", strerror(errno));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bind(sock_fd, (struct sockaddr*)&addr, sizeof addr) != 0) {
|
if (bind(sock_fd, (struct sockaddr*)&addr, sizeof addr) != 0) {
|
||||||
UC_LOGF(UC_LL_ERROR, LMAIN, "Cannot bind socket to port %u : %s\n",
|
UC_LOGF(UC_LL_ERROR, LMAIN, "Cannot bind socket to port %u : %s",
|
||||||
local_port, strerror(errno));
|
local_port, strerror(errno));
|
||||||
close(sock_fd);
|
close(sock_fd);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user