blob: 1ab5212d8f2da05e26c22936bed2502333703a1c [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 */
21#include <assert.h>
22
23#include <osmocom/core/logging.h>
24#include <osmocom/core/utils.h>
25#include <osmocom/core/ringb.h>
26#include <osmocom/vty/logging_rbvty.h>
27
28enum {
29 DRLL,
30 DCC,
31 DMM,
32};
33
34static const struct log_info_cat default_categories[] = {
35 [DRLL] = {
36 .name = "DRLL",
37 .description = "A-bis Radio Link Layer (RLL)",
38 .color = "\033[1;31m",
39 .enabled = 1, .loglevel = LOGL_NOTICE,
40 },
41 [DCC] = {
42 .name = "DCC",
43 .description = "Layer3 Call Control (CC)",
44 .color = "\033[1;32m",
45 .enabled = 1, .loglevel = LOGL_NOTICE,
46 },
47 [DMM] = {
48 .name = NULL,
49 .description = "Layer3 Mobility Management (MM)",
50 .color = "\033[1;33m",
51 .enabled = 1, .loglevel = LOGL_NOTICE,
52 },
53};
54
55const struct log_info log_info = {
56 .cat = default_categories,
57 .num_cat = ARRAY_SIZE(default_categories),
58};
59
60int main(int argc, char **argv)
61{
62 struct log_target *ringbuf_target;
63
64 log_init(&log_info, NULL);
65 ringbuf_target = log_target_create_rbvty(NULL, 0x1000);
66 log_add_target(ringbuf_target);
67 log_set_all_filter(ringbuf_target, 1);
68 log_set_print_filename(ringbuf_target, 0);
69
70 log_parse_category_mask(ringbuf_target, "DRLL:DCC");
71 log_parse_category_mask(ringbuf_target, "DRLL");
72 DEBUGP(DCC, "You should not see this\n");
73
74 log_parse_category_mask(ringbuf_target, "DRLL:DCC");
75 DEBUGP(DRLL, "You should see this\n");
76 DEBUGP(DCC, "You should see this\n");
77 DEBUGP(DMM, "You should not see this\n");
78 fprintf(stderr, ringbuffer_get_nth(ringbuf_target->tgt_rbvty.rb, 0));
79 fprintf(stderr, ringbuffer_get_nth(ringbuf_target->tgt_rbvty.rb, 1));
80 assert(!ringbuffer_get_nth(ringbuf_target->tgt_rbvty.rb, 2));
81
82 return 0;
83}