2013-02-21 05:16:29 +00:00
|
|
|
/* simple test for the debug interface */
|
|
|
|
/*
|
|
|
|
* (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* (C) 2012-2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2017-12-09 13:03:29 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2013-02-21 05:16:29 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2017-12-09 13:03:29 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2013-02-21 05:16:29 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <osmocom/core/logging.h>
|
|
|
|
#include <osmocom/core/utils.h>
|
2015-03-30 12:22:14 +00:00
|
|
|
#include <osmocom/core/loggingrb.h>
|
2013-02-21 05:16:29 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
DRLL,
|
|
|
|
DCC,
|
|
|
|
DMM,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct log_info_cat default_categories[] = {
|
|
|
|
[DRLL] = {
|
|
|
|
.name = "DRLL",
|
|
|
|
.description = "A-bis Radio Link Layer (RLL)",
|
|
|
|
.color = "\033[1;31m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DCC] = {
|
|
|
|
.name = "DCC",
|
|
|
|
.description = "Layer3 Call Control (CC)",
|
|
|
|
.color = "\033[1;32m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
[DMM] = {
|
|
|
|
.name = NULL,
|
|
|
|
.description = "Layer3 Mobility Management (MM)",
|
|
|
|
.color = "\033[1;33m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_NOTICE,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct log_info log_info = {
|
|
|
|
.cat = default_categories,
|
|
|
|
.num_cat = ARRAY_SIZE(default_categories),
|
|
|
|
};
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct log_target *ringbuf_target;
|
|
|
|
|
|
|
|
log_init(&log_info, NULL);
|
2015-03-30 12:22:14 +00:00
|
|
|
ringbuf_target = log_target_create_rb(0x1000);
|
2013-02-21 05:16:29 +00:00
|
|
|
log_add_target(ringbuf_target);
|
|
|
|
log_set_all_filter(ringbuf_target, 1);
|
|
|
|
log_set_print_filename(ringbuf_target, 0);
|
|
|
|
|
|
|
|
log_parse_category_mask(ringbuf_target, "DRLL:DCC");
|
|
|
|
log_parse_category_mask(ringbuf_target, "DRLL");
|
|
|
|
DEBUGP(DCC, "You should not see this\n");
|
|
|
|
|
|
|
|
log_parse_category_mask(ringbuf_target, "DRLL:DCC");
|
|
|
|
DEBUGP(DRLL, "You should see this\n");
|
|
|
|
DEBUGP(DCC, "You should see this\n");
|
|
|
|
DEBUGP(DMM, "You should not see this\n");
|
2015-04-11 17:33:10 +00:00
|
|
|
fprintf(stderr, "%s", log_target_rb_get(ringbuf_target, 0));
|
|
|
|
fprintf(stderr, "%s", log_target_rb_get(ringbuf_target, 1));
|
2015-03-30 12:22:14 +00:00
|
|
|
OSMO_ASSERT(!log_target_rb_get(ringbuf_target, 2));
|
2013-02-21 05:16:29 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|