blob: 9957b536e79ab1dc53991be7df1769c690363c61 [file] [log] [blame]
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +00001/* simple test for the debug interface */
2/*
3 * (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * (C) 2012-2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +000021
22#include <osmocom/core/logging.h>
23#include <osmocom/core/utils.h>
24#include <osmocom/core/ringb.h>
25#include <osmocom/vty/logging_rbvty.h>
26
27enum {
28 DRLL,
29 DCC,
30 DMM,
31};
32
33static const struct log_info_cat default_categories[] = {
34 [DRLL] = {
35 .name = "DRLL",
36 .description = "A-bis Radio Link Layer (RLL)",
37 .color = "\033[1;31m",
38 .enabled = 1, .loglevel = LOGL_NOTICE,
39 },
40 [DCC] = {
41 .name = "DCC",
42 .description = "Layer3 Call Control (CC)",
43 .color = "\033[1;32m",
44 .enabled = 1, .loglevel = LOGL_NOTICE,
45 },
46 [DMM] = {
47 .name = NULL,
48 .description = "Layer3 Mobility Management (MM)",
49 .color = "\033[1;33m",
50 .enabled = 1, .loglevel = LOGL_NOTICE,
51 },
52};
53
54const struct log_info log_info = {
55 .cat = default_categories,
56 .num_cat = ARRAY_SIZE(default_categories),
57};
58
59int main(int argc, char **argv)
60{
61 struct log_target *ringbuf_target;
62
63 log_init(&log_info, NULL);
64 ringbuf_target = log_target_create_rbvty(NULL, 0x1000);
65 log_add_target(ringbuf_target);
66 log_set_all_filter(ringbuf_target, 1);
67 log_set_print_filename(ringbuf_target, 0);
68
69 log_parse_category_mask(ringbuf_target, "DRLL:DCC");
70 log_parse_category_mask(ringbuf_target, "DRLL");
71 DEBUGP(DCC, "You should not see this\n");
72
73 log_parse_category_mask(ringbuf_target, "DRLL:DCC");
74 DEBUGP(DRLL, "You should see this\n");
75 DEBUGP(DCC, "You should see this\n");
76 DEBUGP(DMM, "You should not see this\n");
77 fprintf(stderr, ringbuffer_get_nth(ringbuf_target->tgt_rbvty.rb, 0));
78 fprintf(stderr, ringbuffer_get_nth(ringbuf_target->tgt_rbvty.rb, 1));
Katerina Barone-Adesi008e53b2013-03-03 10:36:52 +000079 OSMO_ASSERT(!ringbuffer_get_nth(ringbuf_target->tgt_rbvty.rb, 2));
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +000080
81 return 0;
82}