mirror of https://gerrit.osmocom.org/libosmocore
logging: Copy the filter_fn and fix the IMSI filter in OpenBSC
The filter_fn has not been copied into the new structure breaking the imsi and other filters in OpenBSC. Looking at the code we should also introduce a callback for the reset of the context so we could use subscr_get/subscr_put on the subscriber structure.
This commit is contained in:
parent
6308c29711
commit
b7d0f4686b
|
@ -768,6 +768,7 @@ int log_init(const struct log_info *inf, void *ctx)
|
||||||
if (!osmo_log_info)
|
if (!osmo_log_info)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
osmo_log_info->filter_fn = inf->filter_fn;
|
||||||
osmo_log_info->num_cat_user = inf->num_cat;
|
osmo_log_info->num_cat_user = inf->num_cat;
|
||||||
/* total number = number of user cat + library cat */
|
/* total number = number of user cat + library cat */
|
||||||
osmo_log_info->num_cat = inf->num_cat + ARRAY_SIZE(internal_cat);
|
osmo_log_info->num_cat = inf->num_cat + ARRAY_SIZE(internal_cat);
|
||||||
|
|
|
@ -21,12 +21,16 @@
|
||||||
#include <osmocom/core/logging.h>
|
#include <osmocom/core/logging.h>
|
||||||
#include <osmocom/core/utils.h>
|
#include <osmocom/core/utils.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DRLL,
|
DRLL,
|
||||||
DCC,
|
DCC,
|
||||||
DMM,
|
DMM,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int filter_called = 0;
|
||||||
|
|
||||||
static const struct log_info_cat default_categories[] = {
|
static const struct log_info_cat default_categories[] = {
|
||||||
[DRLL] = {
|
[DRLL] = {
|
||||||
.name = "DRLL",
|
.name = "DRLL",
|
||||||
|
@ -48,9 +52,17 @@ static const struct log_info_cat default_categories[] = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int test_filter(const struct log_context *ctx, struct log_target *target)
|
||||||
|
{
|
||||||
|
filter_called += 1;
|
||||||
|
/* omit everything */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const struct log_info log_info = {
|
const struct log_info log_info = {
|
||||||
.cat = default_categories,
|
.cat = default_categories,
|
||||||
.num_cat = ARRAY_SIZE(default_categories),
|
.num_cat = ARRAY_SIZE(default_categories),
|
||||||
|
.filter_fn = test_filter,
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -71,6 +83,11 @@ int main(int argc, char **argv)
|
||||||
DEBUGP(DRLL, "You should see this\n");
|
DEBUGP(DRLL, "You should see this\n");
|
||||||
DEBUGP(DCC, "You should see this\n");
|
DEBUGP(DCC, "You should see this\n");
|
||||||
DEBUGP(DMM, "You should not see this\n");
|
DEBUGP(DMM, "You should not see this\n");
|
||||||
|
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);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue