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