blob: 00870705a7bd11f107c3aea31bf9c0425bb8a4ef [file] [log] [blame]
dburgess82c46ff2011-10-07 02:40:51 +00001/*
2* Copyright 2009 Free Software Foundation, Inc.
3* Copyright 2010 Kestrel Signal Processing, Inc.
4*
Pau Espin Pedrol21d03d32019-07-22 12:05:52 +02005* SPDX-License-Identifier: AGPL-3.0+
dburgess82c46ff2011-10-07 02:40:51 +00006*
7* This software is distributed under the terms of the GNU Affero Public License.
8* See the COPYING file in the main directory for details.
9*
10* This use of this software may be subject to additional restrictions.
11* See the LEGAL file in the main directory for details.
12
13 This program is free software: you can redistribute it and/or modify
14 it under the terms of the GNU Affero General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Affero General Public License for more details.
22
23 You should have received a copy of the GNU Affero General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
25
26*/
27
28#include <iostream>
29#include <iterator>
30
31#include "Logger.h"
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010032extern "C" {
Pau Espin Pedrole1977fc2018-04-16 14:50:11 +020033#include <osmocom/core/msgb.h>
34#include <osmocom/core/talloc.h>
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010035#include <osmocom/core/application.h>
36#include <osmocom/core/utils.h>
37#include "debug.h"
38}
39
40#define MYCAT 0
dburgess82c46ff2011-10-07 02:40:51 +000041
dburgess82c46ff2011-10-07 02:40:51 +000042int main(int argc, char *argv[])
43{
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010044 struct log_info_cat categories[1];
45 struct log_info linfo;
46 categories[MYCAT] = {
47 "MYCAT",
48 NULL,
49 "Whatever",
50 LOGL_NOTICE,
51 1,
52 };
53 linfo.cat = categories;
54 linfo.num_cat = ARRAY_SIZE(categories);
dburgess82c46ff2011-10-07 02:40:51 +000055
Pau Espin Pedrole1977fc2018-04-16 14:50:11 +020056 void *tall_ctx = talloc_named_const(NULL, 1, "OsmoTRX context");
57 msgb_talloc_ctx_init(tall_ctx, 0);
58
59 osmo_init_logging2(tall_ctx, &linfo);
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010060
61 log_set_use_color(osmo_stderr_target, 0);
62 log_set_print_filename(osmo_stderr_target, 0);
63 log_set_print_level(osmo_stderr_target, 1);
64
Pau Espin Pedrol3b78cbf2018-04-25 16:43:02 +020065 Log(MYCAT, LOGL_FATAL, __BASE_FILE__, __LINE__).get() << "testing the logger.";
66 Log(MYCAT, LOGL_ERROR, __BASE_FILE__, __LINE__).get() << "testing the logger.";
67 Log(MYCAT, LOGL_NOTICE, __BASE_FILE__, __LINE__).get() << "testing the logger.";
68 Log(MYCAT, LOGL_INFO, __BASE_FILE__, __LINE__).get() << "testing the logger.";
69 Log(MYCAT, LOGL_DEBUG, __BASE_FILE__, __LINE__).get() << "testing the logger.";
dburgess82c46ff2011-10-07 02:40:51 +000070}