blob: 5e51ce7af1bf6c697a18bde936e69a181fef01b7 [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*
5*
6* This software is distributed under the terms of the GNU Affero Public License.
7* See the COPYING file in the main directory for details.
8*
9* This use of this software may be subject to additional restrictions.
10* See the LEGAL file in the main directory for details.
11
12 This program is free software: you can redistribute it and/or modify
13 it under the terms of the GNU Affero General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU Affero General Public License for more details.
21
22 You should have received a copy of the GNU Affero General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
24
25*/
26
27#include <iostream>
28#include <iterator>
29
30#include "Logger.h"
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010031extern "C" {
Pau Espin Pedrole1977fc2018-04-16 14:50:11 +020032#include <osmocom/core/msgb.h>
33#include <osmocom/core/talloc.h>
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010034#include <osmocom/core/application.h>
35#include <osmocom/core/utils.h>
36#include "debug.h"
37}
38
39#define MYCAT 0
dburgess82c46ff2011-10-07 02:40:51 +000040
dburgess82c46ff2011-10-07 02:40:51 +000041int main(int argc, char *argv[])
42{
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010043 struct log_info_cat categories[1];
44 struct log_info linfo;
45 categories[MYCAT] = {
46 "MYCAT",
47 NULL,
48 "Whatever",
49 LOGL_NOTICE,
50 1,
51 };
52 linfo.cat = categories;
53 linfo.num_cat = ARRAY_SIZE(categories);
dburgess82c46ff2011-10-07 02:40:51 +000054
Pau Espin Pedrole1977fc2018-04-16 14:50:11 +020055 void *tall_ctx = talloc_named_const(NULL, 1, "OsmoTRX context");
56 msgb_talloc_ctx_init(tall_ctx, 0);
57
58 osmo_init_logging2(tall_ctx, &linfo);
Pau Espin Pedrol3da1f832018-02-20 20:01:10 +010059
60 log_set_use_color(osmo_stderr_target, 0);
61 log_set_print_filename(osmo_stderr_target, 0);
62 log_set_print_level(osmo_stderr_target, 1);
63
Pau Espin Pedrol3b78cbf2018-04-25 16:43:02 +020064 Log(MYCAT, LOGL_FATAL, __BASE_FILE__, __LINE__).get() << "testing the logger.";
65 Log(MYCAT, LOGL_ERROR, __BASE_FILE__, __LINE__).get() << "testing the logger.";
66 Log(MYCAT, LOGL_NOTICE, __BASE_FILE__, __LINE__).get() << "testing the logger.";
67 Log(MYCAT, LOGL_INFO, __BASE_FILE__, __LINE__).get() << "testing the logger.";
68 Log(MYCAT, LOGL_DEBUG, __BASE_FILE__, __LINE__).get() << "testing the logger.";
dburgess82c46ff2011-10-07 02:40:51 +000069}