dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Free Software Foundation, Inc. |
| 3 | * Copyright 2010 Kestrel Signal Processing, Inc. |
| 4 | * |
Pau Espin Pedrol | 21d03d3 | 2019-07-22 12:05:52 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: AGPL-3.0+ |
dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 6 | * |
| 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 Pedrol | 3da1f83 | 2018-02-20 20:01:10 +0100 | [diff] [blame] | 32 | extern "C" { |
Pau Espin Pedrol | e1977fc | 2018-04-16 14:50:11 +0200 | [diff] [blame] | 33 | #include <osmocom/core/msgb.h> |
| 34 | #include <osmocom/core/talloc.h> |
Pau Espin Pedrol | 3da1f83 | 2018-02-20 20:01:10 +0100 | [diff] [blame] | 35 | #include <osmocom/core/application.h> |
| 36 | #include <osmocom/core/utils.h> |
| 37 | #include "debug.h" |
| 38 | } |
| 39 | |
| 40 | #define MYCAT 0 |
dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 41 | |
dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 42 | int main(int argc, char *argv[]) |
| 43 | { |
Pau Espin Pedrol | 3da1f83 | 2018-02-20 20:01:10 +0100 | [diff] [blame] | 44 | 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); |
dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 55 | |
Pau Espin Pedrol | e1977fc | 2018-04-16 14:50:11 +0200 | [diff] [blame] | 56 | 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 Pedrol | 3da1f83 | 2018-02-20 20:01:10 +0100 | [diff] [blame] | 60 | |
| 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 Pedrol | 3b78cbf | 2018-04-25 16:43:02 +0200 | [diff] [blame] | 65 | 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."; |
dburgess | 82c46ff | 2011-10-07 02:40:51 +0000 | [diff] [blame] | 70 | } |