int main(int argc, char **argv) { void *ctx = talloc_named_const(NULL, 0, "oap_client_test"); msgb_talloc_ctx_init(ctx, 0); osmo_init_logging2(ctx, &info); OSMO_ASSERT(osmo_stderr_target); log_set_use_color(osmo_stderr_target, 0); log_set_print_timestamp(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); log_set_print_category(osmo_stderr_target, 1); log_parse_category_mask(osmo_stderr_target, "DLOAP,1"); test_oap_api(); printf("Done\n"); return 0; }
/** * Initialize the logging system for the virtual physical layer. */ int ms_log_init(char *cat_mask) { struct log_target *stderr_target; log_init(&ms_log_info, NULL); stderr_target = log_target_create_stderr(); if (!stderr) return -1; log_add_target(stderr_target); log_set_all_filter(stderr_target, 1); //log_set_log_level(stderr_target, 1); log_set_print_filename(stderr_target, 1); log_set_use_color(stderr_target, 0); log_set_print_timestamp(stderr_target, 1); log_set_print_category(stderr_target, 1); if (cat_mask) log_parse_category_mask(stderr_target, cat_mask); return 0; }
int main(int argc, char **argv) { struct log_target *stderr_target; log_init(&log_info, NULL); stderr_target = log_target_create_stderr(); log_add_target(stderr_target); log_set_all_filter(stderr_target, 1); log_set_print_filename(stderr_target, 0); log_set_print_category(stderr_target, 1); log_set_use_color(stderr_target, 0); log_parse_category_mask(stderr_target, "DRLL:DCC"); log_parse_category_mask(stderr_target, "DRLL"); select_output = 0; DEBUGP(DCC, "You should not see this\n"); if (log_check_level(DMM, LOGL_DEBUG) != 0) fprintf(stderr, "log_check_level did not catch this case\n"); log_parse_category_mask(stderr_target, "DRLL:DCC"); DEBUGP(DRLL, "You should see this\n"); OSMO_ASSERT(log_check_level(DRLL, LOGL_DEBUG) != 0); DEBUGP(DCC, "You should see this\n"); OSMO_ASSERT(log_check_level(DCC, LOGL_DEBUG) != 0); DEBUGP(DMM, "You should not see this\n"); OSMO_ASSERT(log_check_level(DMM, LOGL_DEBUG) == 0); OSMO_ASSERT(filter_called == 0); log_set_all_filter(stderr_target, 0); DEBUGP(DRLL, "You should not see this and filter is called\n"); OSMO_ASSERT(filter_called == 1); OSMO_ASSERT(log_check_level(DRLL, LOGL_DEBUG) == 0); OSMO_ASSERT(filter_called == 2); DEBUGP(DRLL, "You should not see this\n"); OSMO_ASSERT(filter_called == 3); select_output = 1; DEBUGP(DRLL, "You should see this\n"); OSMO_ASSERT(filter_called == 5); /* called twice on output */ /* Make sure out-of-bounds category maps to DLGLOBAL */ log_parse_category_mask(stderr_target, "DLGLOBAL,1"); /* For IDs out of bounds of the overall osmo_log_info array */ DEBUGP(osmo_log_info->num_cat + 1, "You should see this on DLGLOBAL (a)\n"); DEBUGP(osmo_log_info->num_cat + 100, "You should see this on DLGLOBAL (b)\n"); DEBUGP(osmo_log_info->num_cat, "You should see this on DLGLOBAL (c)\n"); /* For IDs out of bounds of the user categories part */ DEBUGP(log_info.num_cat + 1, "You should see this on DLGLOBAL (d)\n"); DEBUGP(log_info.num_cat, "You should see this on DLGLOBAL (e)\n"); /* Check log_set_category_filter() with internal categories */ log_parse_category_mask(stderr_target, "DLGLOBAL,3"); DEBUGP(DLGLOBAL, "You should not see this (DLGLOBAL not on DEBUG)\n"); log_set_category_filter(stderr_target, DLGLOBAL, 1, LOGL_DEBUG); DEBUGP(DLGLOBAL, "You should see this (DLGLOBAL on DEBUG)\n"); return 0; }