Implement setting log mask string on a destination.
Improve logging docs
This commit is contained in:
+53
-3
@@ -51,12 +51,15 @@ START_TEST (test_logfile_location)
|
||||
fail_if(dest == NULL);
|
||||
uc_log_add_destination(dest);
|
||||
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n");
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n");
|
||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n");
|
||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n");
|
||||
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n");
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
||||
fail_if(st.st_size != 76*2, "was %ld\n", (long)st.st_size);
|
||||
fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size);
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_logfile_no_location)
|
||||
@@ -361,6 +364,52 @@ START_TEST (test_logfile_raw)
|
||||
fail_if(st.st_size != 14*2, "was %ld\n", (long)st.st_size);
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_logfile_dest_mask)
|
||||
|
||||
struct uc_log_module m[] = {
|
||||
{
|
||||
.id = 0,
|
||||
.short_name = "MOD1",
|
||||
.long_name = "Module 1",
|
||||
.log_level = UC_LL_WARNING,
|
||||
},
|
||||
{
|
||||
.id = 1,
|
||||
.short_name = "MOD2",
|
||||
.long_name = "Module 2",
|
||||
.log_level = UC_LL_WARNING,
|
||||
}
|
||||
};
|
||||
struct uc_log_modules mods = {
|
||||
.mods = m,
|
||||
.cnt = 2,
|
||||
};
|
||||
struct stat st;
|
||||
struct uc_log_destination *dest;
|
||||
int rc;
|
||||
|
||||
uc_log_init(&mods);
|
||||
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 1);
|
||||
fail_if(dest == NULL);
|
||||
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);
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
||||
fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size);
|
||||
|
||||
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, 1, "Lorum ipson %d\n", 1);
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
||||
fail_if(st.st_size != 14*2, "was %ld\n", (long)st.st_size);
|
||||
END_TEST
|
||||
|
||||
|
||||
Suite *logging_suite(void)
|
||||
{
|
||||
@@ -374,6 +423,7 @@ Suite *logging_suite(void)
|
||||
tcase_add_test(tc1, test_logfile_loglevel_surpressed_module);
|
||||
tcase_add_test(tc1, test_logfile_reopen_files);
|
||||
tcase_add_test(tc1, test_logfile_remove_dest);
|
||||
tcase_add_test(tc1, test_logfile_dest_mask);
|
||||
|
||||
if (access("/dev/full", R_OK) == 0) {
|
||||
tcase_add_test(tc1, test_logfile_full_filesystem);
|
||||
|
||||
Reference in New Issue
Block a user