blob: 48b039b50723a7911aaf6e31475ed0669886123b [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*
2 * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +01003 * (C) 2009-2014 by Holger Hans Peter Freyther
Harald Welte3fb0b6f2010-05-19 19:02:52 +02004 * All Rights Reserved
5 *
Harald Weltee08da972017-11-13 01:00:26 +09006 * SPDX-License-Identifier: GPL-2.0+
7 *
Harald Welte3fb0b6f2010-05-19 19:02:52 +02008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24#include <stdlib.h>
25#include <string.h>
26
Harald Welte28222962011-02-18 20:37:04 +010027#include "../../config.h"
28
Pablo Neira Ayuso83419342011-03-22 16:36:13 +010029#include <osmocom/core/talloc.h>
30#include <osmocom/core/logging.h>
Neels Hofmeyrba0762d2018-09-10 13:56:03 +020031#include <osmocom/core/logging_internal.h>
Pablo Neira Ayuso83419342011-03-22 16:36:13 +010032#include <osmocom/core/utils.h>
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +000033#include <osmocom/core/strrb.h>
34#include <osmocom/core/loggingrb.h>
Harald Welteaa00f992016-12-02 15:30:02 +010035#include <osmocom/core/gsmtap.h>
Harald Weltee4d9a2c2020-09-27 11:28:58 +020036#include <osmocom/core/application.h>
Harald Welte3fb0b6f2010-05-19 19:02:52 +020037
38#include <osmocom/vty/command.h>
39#include <osmocom/vty/buffer.h>
40#include <osmocom/vty/vty.h>
41#include <osmocom/vty/telnet_interface.h>
42#include <osmocom/vty/logging.h>
43
Harald Welte28222962011-02-18 20:37:04 +010044#define LOG_STR "Configure logging sub-system\n"
Neels Hofmeyrba0762d2018-09-10 13:56:03 +020045#define LEVEL_STR "Set the log level for a specified category\n"
46
Neels Hofmeyr9540c242018-09-12 00:20:50 +020047#define CATEGORY_ALL_STR "Deprecated alias for 'force-all'\n"
48#define FORCE_ALL_STR \
49 "Globally force all logging categories to a specific level. This is released by the" \
50 " 'no logging level force-all' command. Note: any 'logging level <category> <level>'" \
51 " commands will have no visible effect after this, until the forced level is released.\n"
52#define NO_FORCE_ALL_STR \
53 "Release any globally forced log level set with 'logging level force-all <level>'\n"
Neels Hofmeyrba0762d2018-09-10 13:56:03 +020054
Neels Hofmeyr9540c242018-09-12 00:20:50 +020055#define LOG_LEVEL_ARGS "(debug|info|notice|error|fatal)"
Neels Hofmeyrba0762d2018-09-10 13:56:03 +020056#define LOG_LEVEL_STRS \
57 "Log debug messages and higher levels\n" \
58 "Log informational messages and higher levels\n" \
59 "Log noticeable messages and higher levels\n" \
60 "Log error messages and higher levels\n" \
61 "Log only fatal messages\n"
62
Neels Hofmeyr9540c242018-09-12 00:20:50 +020063#define EVERYTHING_STR "Deprecated alias for 'no logging level force-all'\n"
Harald Welte28222962011-02-18 20:37:04 +010064
Harald Welte8c648252017-10-16 15:17:03 +020065/*! \file logging_vty.c
Neels Hofmeyr87e45502017-06-20 00:17:59 +020066 * Configuration of logging from VTY
Harald Welte96e2a002017-06-12 21:44:18 +020067 *
Harald Welte8c648252017-10-16 15:17:03 +020068 * This module implements
69 * - functions that permit configuration of the libosmocore logging
70 * framework from VTY commands in the configure -> logging node.
71 *
72 * - functions that permit logging *to* a VTY session. Basically each
73 * VTY session gets its own log target, with configurable
74 * per-subsystem log levels. This is performed internally via the
75 * \ref log_target_create_vty function.
76 *
77 * You have to call \ref logging_vty_add_cmds from your application
78 * once to enable both of the above.
79 *
Harald Welte96e2a002017-06-12 21:44:18 +020080 */
81
Harald Welte76e72ab2011-02-17 15:52:39 +010082static void _vty_output(struct log_target *tgt,
83 unsigned int level, const char *line)
Harald Welte3fb0b6f2010-05-19 19:02:52 +020084{
85 struct vty *vty = tgt->tgt_vty.vty;
86 vty_out(vty, "%s", line);
87 /* This is an ugly hack, but there is no easy way... */
88 if (strchr(line, '\n'))
89 vty_out(vty, "\r");
90}
91
92struct log_target *log_target_create_vty(struct vty *vty)
93{
94 struct log_target *target;
95
96 target = log_target_create();
97 if (!target)
98 return NULL;
99
100 target->tgt_vty.vty = vty;
101 target->output = _vty_output;
102 return target;
103}
104
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200105/*! Get tgt with log lock acquired, return and release lock with warning if tgt
106 * is not found. Lock must be released later with log_tgt_mutex_unlock().
107 */
108#define ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt) \
109 do { \
110 log_tgt_mutex_lock(); \
111 tgt = osmo_log_vty2tgt(vty); \
112 if (!(tgt)) { \
113 log_tgt_mutex_unlock(); \
114 return CMD_WARNING; \
115 } \
116 } while (0)
117
118#define RET_WITH_UNLOCK(ret) \
119 do { \
120 log_tgt_mutex_unlock(); \
121 return (ret); \
122 } while (0)
123
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200124DEFUN(enable_logging,
125 enable_logging_cmd,
126 "logging enable",
127 LOGGING_STR
128 "Enables logging to this vty\n")
129{
130 struct telnet_connection *conn;
131
132 conn = (struct telnet_connection *) vty->priv;
133 if (conn->dbg) {
134 vty_out(vty, "Logging already enabled.%s", VTY_NEWLINE);
135 return CMD_WARNING;
136 }
137
138 conn->dbg = log_target_create_vty(vty);
139 if (!conn->dbg)
140 return CMD_WARNING;
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200141 log_tgt_mutex_lock();
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200142 log_add_target(conn->dbg);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200143 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200144}
145
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200146/*! Get log target associated to VTY console.
147 * \param[in] vty Log target type
148 * \returns Log target (if logging enabled), NULL otherwise
149 * Must be called with mutex osmo_log_tgt_mutex held, see log_tgt_mutex_lock.
150 */
Harald Weltea62648b2011-02-18 21:03:27 +0100151struct log_target *osmo_log_vty2tgt(struct vty *vty)
152{
153 struct telnet_connection *conn;
154
155 if (vty->node == CFG_LOG_NODE)
156 return vty->index;
157
158
159 conn = (struct telnet_connection *) vty->priv;
160 if (!conn->dbg)
161 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
162
163 return conn->dbg;
164}
165
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200166DEFUN(logging_fltr_all,
167 logging_fltr_all_cmd,
168 "logging filter all (0|1)",
169 LOGGING_STR FILTER_STR
170 "Do you want to log all messages?\n"
171 "Only print messages matched by other filters\n"
172 "Bypass filter and print all messages\n")
173{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200174 struct log_target *tgt;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200175
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200176 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200177
Harald Weltea62648b2011-02-18 21:03:27 +0100178 log_set_all_filter(tgt, atoi(argv[0]));
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200179 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200180}
181
182DEFUN(logging_use_clr,
183 logging_use_clr_cmd,
184 "logging color (0|1)",
185 LOGGING_STR "Configure color-printing for log messages\n"
186 "Don't use color for printing messages\n"
187 "Use color for printing messages\n")
188{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200189 struct log_target *tgt;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200190
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200191 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200192
Harald Weltea62648b2011-02-18 21:03:27 +0100193 log_set_use_color(tgt, atoi(argv[0]));
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200194 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200195}
196
197DEFUN(logging_prnt_timestamp,
198 logging_prnt_timestamp_cmd,
199 "logging timestamp (0|1)",
200 LOGGING_STR "Configure log message timestamping\n"
201 "Don't prefix each log message\n"
202 "Prefix each log message with current timestamp\n")
203{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200204 struct log_target *tgt;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200205
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200206 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200207
Harald Weltea62648b2011-02-18 21:03:27 +0100208 log_set_print_timestamp(tgt, atoi(argv[0]));
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200209 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200210}
211
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100212DEFUN(logging_prnt_ext_timestamp,
213 logging_prnt_ext_timestamp_cmd,
214 "logging print extended-timestamp (0|1)",
215 LOGGING_STR "Log output settings\n"
216 "Configure log message timestamping\n"
217 "Don't prefix each log message\n"
218 "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\n")
219{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200220 struct log_target *tgt;
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100221
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200222 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100223
224 log_set_print_extended_timestamp(tgt, atoi(argv[0]));
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200225 RET_WITH_UNLOCK(CMD_SUCCESS);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100226}
227
Pau Espin Pedrol662d10d2021-02-18 18:19:23 +0100228DEFUN(logging_prnt_tid,
229 logging_prnt_tid_cmd,
230 "logging print thread-id (0|1)",
231 LOGGING_STR "Log output settings\n"
232 "Configure log message logging Thread ID\n"
233 "Don't prefix each log message\n"
234 "Prefix each log message with current Thread ID\n")
235{
236 struct log_target *tgt;
237
238 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
239
240 log_set_print_tid(tgt, atoi(argv[0]));
241 RET_WITH_UNLOCK(CMD_SUCCESS);
242}
243
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100244DEFUN(logging_prnt_cat,
245 logging_prnt_cat_cmd,
246 "logging print category (0|1)",
247 LOGGING_STR "Log output settings\n"
248 "Configure log message\n"
249 "Don't prefix each log message\n"
250 "Prefix each log message with category/subsystem name\n")
251{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200252 struct log_target *tgt;
253 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100254
255 log_set_print_category(tgt, atoi(argv[0]));
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200256 RET_WITH_UNLOCK(CMD_SUCCESS);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100257}
258
Neels Hofmeyrbd7bd392018-01-16 01:52:29 +0100259DEFUN(logging_prnt_cat_hex,
260 logging_prnt_cat_hex_cmd,
261 "logging print category-hex (0|1)",
262 LOGGING_STR "Log output settings\n"
263 "Configure log message\n"
264 "Don't prefix each log message\n"
265 "Prefix each log message with category/subsystem nr in hex ('<000b>')\n")
266{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200267 struct log_target *tgt;
Neels Hofmeyrbd7bd392018-01-16 01:52:29 +0100268
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200269 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Neels Hofmeyrbd7bd392018-01-16 01:52:29 +0100270
271 log_set_print_category_hex(tgt, atoi(argv[0]));
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200272 RET_WITH_UNLOCK(CMD_SUCCESS);
Neels Hofmeyrbd7bd392018-01-16 01:52:29 +0100273}
274
Neels Hofmeyr886e5482018-01-16 01:49:37 +0100275DEFUN(logging_prnt_level,
276 logging_prnt_level_cmd,
277 "logging print level (0|1)",
278 LOGGING_STR "Log output settings\n"
279 "Configure log message\n"
280 "Don't prefix each log message\n"
281 "Prefix each log message with the log level name\n")
282{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200283 struct log_target *tgt;
Neels Hofmeyr886e5482018-01-16 01:49:37 +0100284
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200285 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Neels Hofmeyr886e5482018-01-16 01:49:37 +0100286
287 log_set_print_level(tgt, atoi(argv[0]));
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200288 RET_WITH_UNLOCK(CMD_SUCCESS);
Neels Hofmeyr886e5482018-01-16 01:49:37 +0100289}
290
Neels Hofmeyr22772cc2018-02-06 00:52:08 +0100291static const struct value_string logging_print_file_args[] = {
292 { LOG_FILENAME_NONE, "0" },
293 { LOG_FILENAME_PATH, "1" },
294 { LOG_FILENAME_BASENAME, "basename" },
295 { 0, NULL }
296};
297
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100298DEFUN(logging_prnt_file,
299 logging_prnt_file_cmd,
Neels Hofmeyr77ae45d2018-08-27 20:32:36 +0200300 "logging print file (0|1|basename) [last]",
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100301 LOGGING_STR "Log output settings\n"
302 "Configure log message\n"
303 "Don't prefix each log message\n"
304 "Prefix each log message with the source file and line\n"
Neels Hofmeyr77ae45d2018-08-27 20:32:36 +0200305 "Prefix each log message with the source file's basename (strip leading paths) and line\n"
306 "Log source file info at the end of a log line. If omitted, log source file info just"
307 " before the log text.\n")
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100308{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200309 struct log_target *tgt;
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100310
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200311 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100312
Neels Hofmeyr22772cc2018-02-06 00:52:08 +0100313 log_set_print_filename2(tgt, get_string_value(logging_print_file_args, argv[0]));
Neels Hofmeyr77ae45d2018-08-27 20:32:36 +0200314 if (argc > 1)
315 log_set_print_filename_pos(tgt, LOG_FILENAME_POS_LINE_END);
316 else
317 log_set_print_filename_pos(tgt, LOG_FILENAME_POS_HEADER_END);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200318 RET_WITH_UNLOCK(CMD_SUCCESS);
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100319}
320
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200321static void add_category_strings(char **cmd_str_p, char **doc_str_p,
322 const struct log_info *categories)
323{
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +0200324 char buf[128];
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200325 int i;
326 for (i = 0; i < categories->num_cat; i++) {
327 if (categories->cat[i].name == NULL)
328 continue;
329 /* skip the leading 'D' in each category name, hence '+ 1' */
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +0200330 osmo_str_tolower_buf(buf, sizeof(buf), categories->cat[i].name + 1);
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200331 osmo_talloc_asprintf(tall_log_ctx, *cmd_str_p, "%s%s",
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +0200332 i ? "|" : "", buf);
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200333 osmo_talloc_asprintf(tall_log_ctx, *doc_str_p, "%s\n",
334 categories->cat[i].description);
335 }
336}
337
338static void gen_logging_level_cmd_strs(struct cmd_element *cmd,
339 const char *level_args, const char *level_strs)
340{
341 char *cmd_str = NULL;
342 char *doc_str = NULL;
343
344 assert_loginfo(__func__);
345
346 OSMO_ASSERT(cmd->string == NULL);
347 OSMO_ASSERT(cmd->doc == NULL);
348
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200349 osmo_talloc_asprintf(tall_log_ctx, cmd_str, "logging level (");
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200350 osmo_talloc_asprintf(tall_log_ctx, doc_str,
351 LOGGING_STR
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200352 LEVEL_STR);
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200353 add_category_strings(&cmd_str, &doc_str, osmo_log_info);
354 osmo_talloc_asprintf(tall_log_ctx, cmd_str, ") %s", level_args);
355 osmo_talloc_asprintf(tall_log_ctx, doc_str, "%s", level_strs);
356
Harald Weltebebec212020-07-15 12:21:29 +0200357 talloc_set_name_const(cmd_str, "vty_log_level_cmd_str");
358 talloc_set_name_const(doc_str, "vty_log_level_doc_str");
359
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200360 cmd->string = cmd_str;
361 cmd->doc = doc_str;
362}
363
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200364/* logging level (<categories>) (debug|...|fatal) */
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200365DEFUN(logging_level,
366 logging_level_cmd,
Pablo Neira Ayuso04139f12011-03-09 13:05:08 +0100367 NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
368 NULL) /* same thing for helpstr. */
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200369{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200370 struct log_target *tgt;
Harald Weltea62648b2011-02-18 21:03:27 +0100371 int category = log_parse_category(argv[0]);
372 int level = log_parse_level(argv[1]);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200373
Harald Weltea62648b2011-02-18 21:03:27 +0100374 if (level < 0) {
375 vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE);
Pau Espin Pedrol57d11182020-01-02 16:21:14 +0100376 return CMD_WARNING;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200377 }
378
Harald Weltea62648b2011-02-18 21:03:27 +0100379 if (category < 0) {
380 vty_out(vty, "Invalid category `%s'%s", argv[0], VTY_NEWLINE);
Pau Espin Pedrol57d11182020-01-02 16:21:14 +0100381 return CMD_WARNING;
Harald Weltea62648b2011-02-18 21:03:27 +0100382 }
383
Pau Espin Pedrol57d11182020-01-02 16:21:14 +0100384 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
385
Harald Weltea62648b2011-02-18 21:03:27 +0100386 tgt->categories[category].enabled = 1;
387 tgt->categories[category].loglevel = level;
388
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200389 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200390}
391
Neels Hofmeyr28fc0782018-09-12 02:32:02 +0200392DEFUN(logging_level_set_all, logging_level_set_all_cmd,
393 "logging level set-all " LOG_LEVEL_ARGS,
394 LOGGING_STR LEVEL_STR
395 "Once-off set all categories to the given log level. There is no single command"
396 " to take back these changes -- each category is set to the given level, period.\n"
397 LOG_LEVEL_STRS)
398{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200399 struct log_target *tgt;
Neels Hofmeyr28fc0782018-09-12 02:32:02 +0200400 int level = log_parse_level(argv[0]);
401 int i;
Neels Hofmeyrea6f5192018-10-01 15:51:18 +0200402
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200403 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Neels Hofmeyrea6f5192018-10-01 15:51:18 +0200404
Neels Hofmeyr28fc0782018-09-12 02:32:02 +0200405 for (i = 0; i < osmo_log_info->num_cat; i++) {
406 struct log_category *cat = &tgt->categories[i];
407 /* skip empty entries in the array */
408 if (!osmo_log_info->cat[i].name)
409 continue;
410
411 cat->enabled = 1;
412 cat->loglevel = level;
413 }
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200414 RET_WITH_UNLOCK(CMD_SUCCESS);
Neels Hofmeyr28fc0782018-09-12 02:32:02 +0200415}
416
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200417/* logging level (<categories>) everything */
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +0200418DEFUN_DEPRECATED(deprecated_logging_level_everything, deprecated_logging_level_everything_cmd,
419 NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
420 NULL) /* same thing for helpstr. */
421{
422 vty_out(vty, "%% Ignoring deprecated logging level 'everything' keyword%s", VTY_NEWLINE);
423 return CMD_SUCCESS;
424}
425
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200426DEFUN(logging_level_force_all, logging_level_force_all_cmd,
427 "logging level force-all " LOG_LEVEL_ARGS,
428 LOGGING_STR LEVEL_STR FORCE_ALL_STR LOG_LEVEL_STRS)
429{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200430 struct log_target *tgt;
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200431 int level = log_parse_level(argv[0]);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200432
433 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
434
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200435 log_set_log_level(tgt, level);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200436 RET_WITH_UNLOCK(CMD_SUCCESS);
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200437}
438
439DEFUN(no_logging_level_force_all, no_logging_level_force_all_cmd,
440 "no logging level force-all",
441 NO_STR LOGGING_STR LEVEL_STR NO_FORCE_ALL_STR)
442{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200443 struct log_target *tgt;
444
445 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
446
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200447 log_set_log_level(tgt, 0);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200448 RET_WITH_UNLOCK(CMD_SUCCESS);
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200449}
450
451/* 'logging level all (debug|...|fatal)' */
452ALIAS_DEPRECATED(logging_level_force_all, deprecated_logging_level_all_cmd,
453 "logging level all " LOG_LEVEL_ARGS,
454 LOGGING_STR LEVEL_STR CATEGORY_ALL_STR LOG_LEVEL_STRS);
455
456/* 'logging level all everything' */
457ALIAS_DEPRECATED(no_logging_level_force_all, deprecated_logging_level_all_everything_cmd,
458 "logging level all everything",
459 LOGGING_STR LEVEL_STR CATEGORY_ALL_STR EVERYTHING_STR);
460
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200461DEFUN(logging_set_category_mask,
462 logging_set_category_mask_cmd,
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200463 "logging set-log-mask MASK",
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200464 LOGGING_STR
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200465 "Set the logmask of this logging target\n"
Neels Hofmeyr84ea2e02017-12-09 05:53:18 +0100466 "List of logging categories to log, e.g. 'abc:mno:xyz'. Available log categories depend on the specific"
467 " application, refer to the 'logging level' command. Optionally add individual log levels like"
468 " 'abc,1:mno,3:xyz,5', where the level numbers are"
469 " " OSMO_STRINGIFY(LOGL_DEBUG) "=" OSMO_STRINGIFY_VAL(LOGL_DEBUG)
470 " " OSMO_STRINGIFY(LOGL_INFO) "=" OSMO_STRINGIFY_VAL(LOGL_INFO)
471 " " OSMO_STRINGIFY(LOGL_NOTICE) "=" OSMO_STRINGIFY_VAL(LOGL_NOTICE)
472 " " OSMO_STRINGIFY(LOGL_ERROR) "=" OSMO_STRINGIFY_VAL(LOGL_ERROR)
473 " " OSMO_STRINGIFY(LOGL_FATAL) "=" OSMO_STRINGIFY_VAL(LOGL_FATAL)
474 "\n")
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200475{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200476 struct log_target *tgt;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200477
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200478 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200479
Harald Weltea62648b2011-02-18 21:03:27 +0100480 log_parse_category_mask(tgt, argv[0]);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200481 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200482}
483
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200484ALIAS_DEPRECATED(logging_set_category_mask,
485 logging_set_category_mask_old_cmd,
486 "logging set log mask MASK",
487 LOGGING_STR
488 "Decide which categories to output.\n"
Neels Hofmeyr84ea2e02017-12-09 05:53:18 +0100489 "Log commands\n" "Mask commands\n"
490 "'set log mask' is deprecated, please refer to the docs of 'set-log-mask' instead\n");
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200491
492
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200493DEFUN(diable_logging,
494 disable_logging_cmd,
495 "logging disable",
496 LOGGING_STR
497 "Disables logging to this vty\n")
498{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200499 struct log_target *tgt;
Harald Weltea62648b2011-02-18 21:03:27 +0100500 struct telnet_connection *conn = (struct telnet_connection *) vty->priv;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200501
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200502 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200503
Harald Weltea62648b2011-02-18 21:03:27 +0100504 log_del_target(tgt);
505 talloc_free(tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200506 conn->dbg = NULL;
Harald Weltea62648b2011-02-18 21:03:27 +0100507
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200508 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200509}
510
511static void vty_print_logtarget(struct vty *vty, const struct log_info *info,
512 const struct log_target *tgt)
513{
514 unsigned int i;
515
516 vty_out(vty, " Global Loglevel: %s%s",
517 log_level_str(tgt->loglevel), VTY_NEWLINE);
518 vty_out(vty, " Use color: %s, Print Timestamp: %s%s",
519 tgt->use_color ? "On" : "Off",
520 tgt->print_timestamp ? "On" : "Off", VTY_NEWLINE);
521
522 vty_out(vty, " Log Level specific information:%s", VTY_NEWLINE);
523
524 for (i = 0; i < info->num_cat; i++) {
525 const struct log_category *cat = &tgt->categories[i];
Daniel Willmann55363a92016-11-15 10:05:51 +0100526 /* Skip categories that were not initialized */
527 if (!info->cat[i].name)
528 continue;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200529 vty_out(vty, " %-10s %-10s %-8s %s%s",
530 info->cat[i].name+1, log_level_str(cat->loglevel),
531 cat->enabled ? "Enabled" : "Disabled",
532 info->cat[i].description,
533 VTY_NEWLINE);
534 }
Harald Welte6d2d4d62013-03-10 09:53:24 +0000535
536 vty_out(vty, " Log Filter 'ALL': %s%s",
Neels Hofmeyr8b86cd72017-02-23 18:03:28 +0100537 tgt->filter_map & (1 << LOG_FLT_ALL) ? "Enabled" : "Disabled",
Harald Welte6d2d4d62013-03-10 09:53:24 +0000538 VTY_NEWLINE);
539
Harald Weltefb84f322013-06-06 07:33:54 +0200540 /* print application specific filters */
541 if (info->print_fn)
542 info->print_fn(vty, info, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200543}
544
545#define SHOW_LOG_STR "Show current logging configuration\n"
546
547DEFUN(show_logging_vty,
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000548 show_logging_vty_cmd,
549 "show logging vty",
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200550 SHOW_STR SHOW_LOG_STR
551 "Show current logging configuration for this vty\n")
552{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200553 struct log_target *tgt;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200554
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200555 ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt);
Harald Weltea62648b2011-02-18 21:03:27 +0100556
557 vty_print_logtarget(vty, osmo_log_info, tgt);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200558 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200559}
560
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000561DEFUN(show_alarms,
562 show_alarms_cmd,
563 "show alarms",
564 SHOW_STR SHOW_LOG_STR
565 "Show the contents of the logging ringbuffer\n")
566{
567 int i, num_alarms;
568 struct osmo_strrb *rb;
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200569 struct log_target *tgt;
570
571 log_tgt_mutex_lock();
572 tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000573 if (!tgt) {
574 vty_out(vty, "%% No alarms, run 'log alarms <2-32700>'%s",
575 VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200576 RET_WITH_UNLOCK(CMD_WARNING);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000577 }
578
579 rb = tgt->tgt_rb.rb;
580 num_alarms = osmo_strrb_elements(rb);
581
582 vty_out(vty, "%% Showing %i alarms%s", num_alarms, VTY_NEWLINE);
583
584 for (i = 0; i < num_alarms; i++)
585 vty_out(vty, "%% %s%s", osmo_strrb_get_nth(rb, i),
586 VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200587 RET_WITH_UNLOCK(CMD_SUCCESS);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000588}
589
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200590gDEFUN(cfg_description, cfg_description_cmd,
591 "description .TEXT",
Thorsten Alteholza81055d2017-03-02 22:13:48 +0100592 "Save human-readable description of the object\n"
Holger Hans Peter Freytherc9b3e062012-07-25 13:02:49 +0200593 "Text until the end of the line\n")
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200594{
595 char **dptr = vty->index_sub;
596
597 if (!dptr) {
598 vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE);
599 return CMD_WARNING;
600 }
601
Holger Hans Peter Freytherff0670e2011-02-24 14:20:41 +0100602 if (*dptr)
603 talloc_free(*dptr);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200604 *dptr = argv_concat(argv, argc, 0);
Holger Hans Peter Freyther6a75d162013-07-14 09:07:11 +0200605 if (!*dptr)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200606 return CMD_WARNING;
607
608 return CMD_SUCCESS;
609}
610
611gDEFUN(cfg_no_description, cfg_no_description_cmd,
612 "no description",
613 NO_STR
614 "Remove description of the object\n")
615{
616 char **dptr = vty->index_sub;
617
618 if (!dptr) {
619 vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE);
620 return CMD_WARNING;
621 }
622
623 if (*dptr) {
624 talloc_free(*dptr);
625 *dptr = NULL;
626 }
627
628 return CMD_SUCCESS;
629}
630
Harald Welte28222962011-02-18 20:37:04 +0100631/* Support for configuration of log targets != the current vty */
632
633struct cmd_node cfg_log_node = {
634 CFG_LOG_NODE,
635 "%s(config-log)# ",
636 1
637};
638
Harald Welte28222962011-02-18 20:37:04 +0100639#ifdef HAVE_SYSLOG_H
640
641#include <syslog.h>
642
643static const int local_sysl_map[] = {
644 [0] = LOG_LOCAL0,
645 [1] = LOG_LOCAL1,
646 [2] = LOG_LOCAL2,
647 [3] = LOG_LOCAL3,
648 [4] = LOG_LOCAL4,
649 [5] = LOG_LOCAL5,
650 [6] = LOG_LOCAL6,
651 [7] = LOG_LOCAL7
652};
653
Harald Weltede79cee2011-02-24 23:47:57 +0100654/* From VTY core code */
655extern struct host host;
656
Harald Welte28222962011-02-18 20:37:04 +0100657static int _cfg_log_syslog(struct vty *vty, int facility)
658{
659 struct log_target *tgt;
660
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200661 log_tgt_mutex_lock();
Harald Welte28222962011-02-18 20:37:04 +0100662 /* First delete the old syslog target, if any */
663 tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL);
664 if (tgt)
665 log_target_destroy(tgt);
666
Harald Weltede79cee2011-02-24 23:47:57 +0100667 tgt = log_target_create_syslog(host.app_info->name, 0, facility);
Harald Welte28222962011-02-18 20:37:04 +0100668 if (!tgt) {
669 vty_out(vty, "%% Unable to open syslog%s", VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200670 RET_WITH_UNLOCK(CMD_WARNING);
Harald Welte28222962011-02-18 20:37:04 +0100671 }
672 log_add_target(tgt);
673
674 vty->index = tgt;
675 vty->node = CFG_LOG_NODE;
676
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200677 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte28222962011-02-18 20:37:04 +0100678}
679
680DEFUN(cfg_log_syslog_local, cfg_log_syslog_local_cmd,
681 "log syslog local <0-7>",
682 LOG_STR "Logging via syslog\n" "Syslog LOCAL facility\n"
683 "Local facility number\n")
684{
685 int local = atoi(argv[0]);
686 int facility = local_sysl_map[local];
687
688 return _cfg_log_syslog(vty, facility);
689}
690
691static struct value_string sysl_level_names[] = {
692 { LOG_AUTHPRIV, "authpriv" },
693 { LOG_CRON, "cron" },
694 { LOG_DAEMON, "daemon" },
695 { LOG_FTP, "ftp" },
696 { LOG_LPR, "lpr" },
697 { LOG_MAIL, "mail" },
698 { LOG_NEWS, "news" },
699 { LOG_USER, "user" },
700 { LOG_UUCP, "uucp" },
701 /* only for value -> string conversion */
702 { LOG_LOCAL0, "local 0" },
703 { LOG_LOCAL1, "local 1" },
704 { LOG_LOCAL2, "local 2" },
705 { LOG_LOCAL3, "local 3" },
706 { LOG_LOCAL4, "local 4" },
707 { LOG_LOCAL5, "local 5" },
708 { LOG_LOCAL6, "local 6" },
709 { LOG_LOCAL7, "local 7" },
710 { 0, NULL }
711};
712
713DEFUN(cfg_log_syslog, cfg_log_syslog_cmd,
714 "log syslog (authpriv|cron|daemon|ftp|lpr|mail|news|user|uucp)",
Holger Hans Peter Freythera4463fd2011-10-03 23:17:36 +0200715 LOG_STR "Logging via syslog\n"
716 "Security/authorization messages facility\n"
717 "Clock daemon (cron/at) facility\n"
718 "General system daemon facility\n"
719 "Ftp daemon facility\n"
720 "Line printer facility\n"
721 "Mail facility\n"
722 "News facility\n"
723 "Generic facility\n"
724 "UUCP facility\n")
Harald Welte28222962011-02-18 20:37:04 +0100725{
726 int facility = get_string_value(sysl_level_names, argv[0]);
727
728 return _cfg_log_syslog(vty, facility);
729}
730
731DEFUN(cfg_no_log_syslog, cfg_no_log_syslog_cmd,
732 "no log syslog",
733 NO_STR LOG_STR "Logging via syslog\n")
734{
735 struct log_target *tgt;
736
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200737 log_tgt_mutex_lock();
Harald Welte28222962011-02-18 20:37:04 +0100738 tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL);
739 if (!tgt) {
740 vty_out(vty, "%% No syslog target found%s",
741 VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200742 RET_WITH_UNLOCK(CMD_WARNING);
Harald Welte28222962011-02-18 20:37:04 +0100743 }
744
745 log_target_destroy(tgt);
746
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200747 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte28222962011-02-18 20:37:04 +0100748}
749#endif /* HAVE_SYSLOG_H */
750
Vadim Yanitskiye7bf4352020-09-09 03:36:48 +0700751DEFUN(cfg_log_systemd_journal, cfg_log_systemd_journal_cmd,
752 "log systemd-journal [raw]",
753 LOG_STR "Logging to systemd-journal\n"
754 "Offload rendering of the meta information (location, category) to systemd\n")
755{
756#ifdef ENABLE_SYSTEMD_LOGGING
757 struct log_target *tgt;
758 bool raw = argc > 0;
759
760 log_tgt_mutex_lock();
761 tgt = log_target_find(LOG_TGT_TYPE_SYSTEMD, NULL);
762 if (tgt == NULL) {
763 tgt = log_target_create_systemd(raw);
764 if (tgt == NULL) {
765 vty_out(vty, "%% Unable to create systemd-journal "
766 "log target%s", VTY_NEWLINE);
767 RET_WITH_UNLOCK(CMD_WARNING);
768 }
769 log_add_target(tgt);
770 } else if (tgt->sd_journal.raw != raw) {
771 log_target_systemd_set_raw(tgt, raw);
772 }
773
774 vty->index = tgt;
775 vty->node = CFG_LOG_NODE;
776
777 RET_WITH_UNLOCK(CMD_SUCCESS);
778#else
779 vty_out(vty, "%% systemd-journal logging is not available "
780 "in this build of libosmocore%s", VTY_NEWLINE);
781 return CMD_WARNING;
782#endif /* ENABLE_SYSTEMD_LOGGING */
783}
784
785DEFUN(cfg_no_log_systemd_journal, cfg_no_log_systemd_journal_cmd,
786 "no log systemd-journal",
787 NO_STR LOG_STR "Logging to systemd-journal\n")
788{
789#ifdef ENABLE_SYSTEMD_LOGGING
790 struct log_target *tgt;
791
792 log_tgt_mutex_lock();
793 tgt = log_target_find(LOG_TGT_TYPE_SYSTEMD, NULL);
794 if (!tgt) {
795 vty_out(vty, "%% No systemd-journal logging active%s", VTY_NEWLINE);
796 RET_WITH_UNLOCK(CMD_WARNING);
797 }
798
799 log_target_destroy(tgt);
800
801 RET_WITH_UNLOCK(CMD_SUCCESS);
802#else
803 vty_out(vty, "%% systemd-journal logging is not available "
804 "in this build of libosmocore%s", VTY_NEWLINE);
805 return CMD_WARNING;
806#endif /* ENABLE_SYSTEMD_LOGGING */
807}
808
Harald Welteaa00f992016-12-02 15:30:02 +0100809DEFUN(cfg_log_gsmtap, cfg_log_gsmtap_cmd,
810 "log gsmtap [HOSTNAME]",
Neels Hofmeyrfd9ec3b2016-12-11 01:48:26 +0100811 LOG_STR "Logging via GSMTAP\n"
812 "Host name to send the GSMTAP logging to (UDP port 4729)\n")
Harald Welteaa00f992016-12-02 15:30:02 +0100813{
Max2f153b52018-01-04 12:25:57 +0100814 const char *hostname = argc ? argv[0] : "127.0.0.1";
Harald Welteaa00f992016-12-02 15:30:02 +0100815 struct log_target *tgt;
816
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200817 log_tgt_mutex_lock();
Harald Welteaa00f992016-12-02 15:30:02 +0100818 tgt = log_target_find(LOG_TGT_TYPE_GSMTAP, hostname);
819 if (!tgt) {
820 tgt = log_target_create_gsmtap(hostname, GSMTAP_UDP_PORT,
821 host.app_info->name, false,
822 true);
823 if (!tgt) {
Max2f153b52018-01-04 12:25:57 +0100824 vty_out(vty, "%% Unable to create GSMTAP log for %s%s",
825 hostname, VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200826 RET_WITH_UNLOCK(CMD_WARNING);
Harald Welteaa00f992016-12-02 15:30:02 +0100827 }
828 log_add_target(tgt);
829 }
830
831 vty->index = tgt;
832 vty->node = CFG_LOG_NODE;
833
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200834 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welteaa00f992016-12-02 15:30:02 +0100835}
836
Harald Welte28222962011-02-18 20:37:04 +0100837DEFUN(cfg_log_stderr, cfg_log_stderr_cmd,
838 "log stderr",
839 LOG_STR "Logging via STDERR of the process\n")
840{
841 struct log_target *tgt;
842
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200843 log_tgt_mutex_lock();
Harald Welte28222962011-02-18 20:37:04 +0100844 tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL);
845 if (!tgt) {
846 tgt = log_target_create_stderr();
847 if (!tgt) {
848 vty_out(vty, "%% Unable to create stderr log%s",
849 VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200850 RET_WITH_UNLOCK(CMD_WARNING);
Harald Welte28222962011-02-18 20:37:04 +0100851 }
852 log_add_target(tgt);
853 }
854
855 vty->index = tgt;
856 vty->node = CFG_LOG_NODE;
857
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200858 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte28222962011-02-18 20:37:04 +0100859}
860
861DEFUN(cfg_no_log_stderr, cfg_no_log_stderr_cmd,
862 "no log stderr",
863 NO_STR LOG_STR "Logging via STDERR of the process\n")
864{
865 struct log_target *tgt;
866
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200867 log_tgt_mutex_lock();
Harald Welte28222962011-02-18 20:37:04 +0100868 tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL);
869 if (!tgt) {
870 vty_out(vty, "%% No stderr logging active%s", VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200871 RET_WITH_UNLOCK(CMD_WARNING);
Harald Welte28222962011-02-18 20:37:04 +0100872 }
873
874 log_target_destroy(tgt);
Harald Weltee4d9a2c2020-09-27 11:28:58 +0200875 osmo_stderr_target = NULL;
Harald Welte28222962011-02-18 20:37:04 +0100876
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200877 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte28222962011-02-18 20:37:04 +0100878}
879
880DEFUN(cfg_log_file, cfg_log_file_cmd,
881 "log file .FILENAME",
882 LOG_STR "Logging to text file\n" "Filename\n")
883{
884 const char *fname = argv[0];
885 struct log_target *tgt;
886
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200887 log_tgt_mutex_lock();
Harald Welte28222962011-02-18 20:37:04 +0100888 tgt = log_target_find(LOG_TGT_TYPE_FILE, fname);
889 if (!tgt) {
890 tgt = log_target_create_file(fname);
891 if (!tgt) {
892 vty_out(vty, "%% Unable to create file `%s'%s",
893 fname, VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200894 RET_WITH_UNLOCK(CMD_WARNING);
Harald Welte28222962011-02-18 20:37:04 +0100895 }
896 log_add_target(tgt);
897 }
898
899 vty->index = tgt;
900 vty->node = CFG_LOG_NODE;
901
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200902 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte28222962011-02-18 20:37:04 +0100903}
904
905
906DEFUN(cfg_no_log_file, cfg_no_log_file_cmd,
907 "no log file .FILENAME",
908 NO_STR LOG_STR "Logging to text file\n" "Filename\n")
909{
910 const char *fname = argv[0];
911 struct log_target *tgt;
912
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200913 log_tgt_mutex_lock();
Harald Welte28222962011-02-18 20:37:04 +0100914 tgt = log_target_find(LOG_TGT_TYPE_FILE, fname);
915 if (!tgt) {
916 vty_out(vty, "%% No such log file `%s'%s",
917 fname, VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200918 RET_WITH_UNLOCK(CMD_WARNING);
Harald Welte28222962011-02-18 20:37:04 +0100919 }
920
921 log_target_destroy(tgt);
922
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200923 RET_WITH_UNLOCK(CMD_SUCCESS);
Harald Welte28222962011-02-18 20:37:04 +0100924}
925
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000926DEFUN(cfg_log_alarms, cfg_log_alarms_cmd,
927 "log alarms <2-32700>",
928 LOG_STR "Logging alarms to osmo_strrb\n"
929 "Maximum number of messages to log\n")
930{
931 struct log_target *tgt;
932 unsigned int rbsize = atoi(argv[0]);
933
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200934
935 log_tgt_mutex_lock();
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000936 tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL);
937 if (tgt)
938 log_target_destroy(tgt);
939
940 tgt = log_target_create_rb(rbsize);
941 if (!tgt) {
942 vty_out(vty, "%% Unable to create osmo_strrb (size %u)%s",
943 rbsize, VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200944 RET_WITH_UNLOCK(CMD_WARNING);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000945 }
946 log_add_target(tgt);
947
948 vty->index = tgt;
949 vty->node = CFG_LOG_NODE;
950
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200951 RET_WITH_UNLOCK(CMD_SUCCESS);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000952}
953
954DEFUN(cfg_no_log_alarms, cfg_no_log_alarms_cmd,
955 "no log alarms",
956 NO_STR LOG_STR "Logging alarms to osmo_strrb\n")
957{
958 struct log_target *tgt;
959
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200960 log_tgt_mutex_lock();
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000961 tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL);
962 if (!tgt) {
963 vty_out(vty, "%% No osmo_strrb target found%s", VTY_NEWLINE);
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200964 RET_WITH_UNLOCK(CMD_WARNING);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000965 }
966
967 log_target_destroy(tgt);
968
Pau Espin Pedrold12f6982019-09-17 18:38:58 +0200969 RET_WITH_UNLOCK(CMD_SUCCESS);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000970}
971
Harald Welte28222962011-02-18 20:37:04 +0100972static int config_write_log_single(struct vty *vty, struct log_target *tgt)
973{
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +0200974 char level_buf[128];
Harald Welte28222962011-02-18 20:37:04 +0100975 int i;
Harald Welte28222962011-02-18 20:37:04 +0100976
977 switch (tgt->type) {
978 case LOG_TGT_TYPE_VTY:
979 return 1;
980 break;
981 case LOG_TGT_TYPE_STDERR:
982 vty_out(vty, "log stderr%s", VTY_NEWLINE);
983 break;
984 case LOG_TGT_TYPE_SYSLOG:
985#ifdef HAVE_SYSLOG_H
986 vty_out(vty, "log syslog %s%s",
987 get_value_string(sysl_level_names,
988 tgt->tgt_syslog.facility),
989 VTY_NEWLINE);
990#endif
991 break;
992 case LOG_TGT_TYPE_FILE:
993 vty_out(vty, "log file %s%s", tgt->tgt_file.fname, VTY_NEWLINE);
994 break;
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000995 case LOG_TGT_TYPE_STRRB:
996 vty_out(vty, "log alarms %zu%s",
997 log_target_rb_avail_size(tgt), VTY_NEWLINE);
998 break;
Harald Welteaa00f992016-12-02 15:30:02 +0100999 case LOG_TGT_TYPE_GSMTAP:
1000 vty_out(vty, "log gsmtap %s%s",
1001 tgt->tgt_gsmtap.hostname, VTY_NEWLINE);
1002 break;
Vadim Yanitskiye7bf4352020-09-09 03:36:48 +07001003 case LOG_TGT_TYPE_SYSTEMD:
1004 vty_out(vty, "log systemd-journal%s%s",
1005 tgt->sd_journal.raw ? " raw" : "",
1006 VTY_NEWLINE);
1007 break;
Harald Welte28222962011-02-18 20:37:04 +01001008 }
1009
Harald Welte0d67f482018-09-25 20:16:14 +02001010 vty_out(vty, " logging filter all %u%s",
Neels Hofmeyr8b86cd72017-02-23 18:03:28 +01001011 tgt->filter_map & (1 << LOG_FLT_ALL) ? 1 : 0, VTY_NEWLINE);
Harald Weltefb84f322013-06-06 07:33:54 +02001012 /* save filters outside of libosmocore, i.e. in app code */
1013 if (osmo_log_info->save_fn)
1014 osmo_log_info->save_fn(vty, osmo_log_info, tgt);
Harald Welte2da47f12012-10-22 19:31:54 +02001015
Harald Welte0d67f482018-09-25 20:16:14 +02001016 vty_out(vty, " logging color %u%s", tgt->use_color ? 1 : 0,
Harald Welte28222962011-02-18 20:37:04 +01001017 VTY_NEWLINE);
Vadim Yanitskiy5c4b9852019-07-28 04:36:37 +07001018 vty_out(vty, " logging print category-hex %d%s",
1019 tgt->print_category_hex ? 1 : 0, VTY_NEWLINE);
Harald Welte0d67f482018-09-25 20:16:14 +02001020 vty_out(vty, " logging print category %d%s",
Michael McTernan78933462015-03-20 15:29:25 +01001021 tgt->print_category ? 1 : 0, VTY_NEWLINE);
Pau Espin Pedrol662d10d2021-02-18 18:19:23 +01001022 vty_out(vty, " logging print thread-id %d%s",
1023 tgt->print_tid ? 1 : 0, VTY_NEWLINE);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +01001024 if (tgt->print_ext_timestamp)
Harald Welte0d67f482018-09-25 20:16:14 +02001025 vty_out(vty, " logging print extended-timestamp 1%s", VTY_NEWLINE);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +01001026 else
Harald Welte0d67f482018-09-25 20:16:14 +02001027 vty_out(vty, " logging timestamp %u%s",
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +01001028 tgt->print_timestamp ? 1 : 0, VTY_NEWLINE);
Neels Hofmeyr886e5482018-01-16 01:49:37 +01001029 if (tgt->print_level)
Harald Welte0d67f482018-09-25 20:16:14 +02001030 vty_out(vty, " logging print level 1%s", VTY_NEWLINE);
Harald Welte8d6ca692021-01-20 17:04:23 +01001031 vty_out(vty, " logging print file %s%s%s",
Neels Hofmeyr22772cc2018-02-06 00:52:08 +01001032 get_value_string(logging_print_file_args, tgt->print_filename2),
Harald Welte8d6ca692021-01-20 17:04:23 +01001033 tgt->print_filename_pos == LOG_FILENAME_POS_LINE_END ? " last" : "",
Neels Hofmeyr22772cc2018-02-06 00:52:08 +01001034 VTY_NEWLINE);
Harald Welte28222962011-02-18 20:37:04 +01001035
Neels Hofmeyr098038a2018-09-11 23:49:13 +02001036 if (tgt->loglevel) {
1037 const char *level_str = get_value_string_or_null(loglevel_strs, tgt->loglevel);
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +02001038 if (!level_str) {
Neels Hofmeyr9540c242018-09-12 00:20:50 +02001039 vty_out(vty, "%% Invalid log level %u for 'force-all'%s",
1040 tgt->loglevel, VTY_NEWLINE);
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +02001041 } else {
1042 osmo_str_tolower_buf(level_buf, sizeof(level_buf), level_str);
1043 vty_out(vty, " logging level force-all %s%s", level_buf, VTY_NEWLINE);
1044 }
Neels Hofmeyr098038a2018-09-11 23:49:13 +02001045 }
Harald Welte28222962011-02-18 20:37:04 +01001046
1047 for (i = 0; i < osmo_log_info->num_cat; i++) {
1048 const struct log_category *cat = &tgt->categories[i];
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +02001049 char cat_name[128];
Neels Hofmeyr098038a2018-09-11 23:49:13 +02001050 const char *level_str;
Harald Welte28222962011-02-18 20:37:04 +01001051
Harald Welte1a02cfc2013-03-19 10:37:39 +01001052 /* skip empty entries in the array */
1053 if (!osmo_log_info->cat[i].name)
1054 continue;
1055
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +02001056 osmo_str_tolower_buf(cat_name, sizeof(cat_name), osmo_log_info->cat[i].name + 1);
Neels Hofmeyr098038a2018-09-11 23:49:13 +02001057
1058 level_str = get_value_string_or_null(loglevel_strs, cat->loglevel);
1059 if (!level_str) {
1060 vty_out(vty, "%% Invalid log level %u for %s%s", cat->loglevel, cat_name,
1061 VTY_NEWLINE);
1062 continue;
1063 }
1064
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +02001065 osmo_str_tolower_buf(level_buf, sizeof(level_buf), level_str);
Harald Welte0d67f482018-09-25 20:16:14 +02001066 vty_out(vty, " logging level %s", cat_name);
Pau Espin Pedrolc21ba152019-08-02 20:32:34 +02001067 vty_out(vty, " %s%s", level_buf, VTY_NEWLINE);
Harald Welte28222962011-02-18 20:37:04 +01001068 }
1069
Harald Welte28222962011-02-18 20:37:04 +01001070 return 1;
1071}
1072
1073static int config_write_log(struct vty *vty)
1074{
Pau Espin Pedrold12f6982019-09-17 18:38:58 +02001075 log_tgt_mutex_lock();
Harald Welte28222962011-02-18 20:37:04 +01001076 struct log_target *dbg = vty->index;
1077
1078 llist_for_each_entry(dbg, &osmo_log_target_list, entry)
1079 config_write_log_single(vty, dbg);
1080
Pau Espin Pedrold12f6982019-09-17 18:38:58 +02001081 log_tgt_mutex_unlock();
Harald Welte28222962011-02-18 20:37:04 +01001082 return 1;
1083}
1084
Harald Welte11eb4b52018-06-09 17:41:31 +02001085static int log_deprecated_func(struct cmd_element *cmd, struct vty *vty, int argc, const char *argv[])
1086{
1087 vty_out(vty, "%% Ignoring deprecated '%s'%s", cmd->string, VTY_NEWLINE);
Vadim Yanitskiy4abda9e2019-11-21 00:19:36 +07001088 return CMD_SUCCESS; /* Otherwise the process would terminate */
Harald Welte11eb4b52018-06-09 17:41:31 +02001089}
1090
1091void logging_vty_add_deprecated_subsys(void *ctx, const char *name)
1092{
1093 struct cmd_element *cmd = talloc_zero(ctx, struct cmd_element);
1094 OSMO_ASSERT(cmd);
Vadim Yanitskiy75c242e2019-11-21 00:06:53 +07001095 cmd->string = talloc_asprintf(cmd, "logging level %s " LOG_LEVEL_ARGS, name);
Harald Welte11eb4b52018-06-09 17:41:31 +02001096 cmd->func = log_deprecated_func;
Neels Hofmeyrba0762d2018-09-10 13:56:03 +02001097 cmd->doc = LEVEL_STR
Harald Welte11eb4b52018-06-09 17:41:31 +02001098 "Deprecated Category\n";
1099 cmd->attr = CMD_ATTR_DEPRECATED;
1100
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001101 install_lib_element(CFG_LOG_NODE, cmd);
Harald Welte11eb4b52018-06-09 17:41:31 +02001102}
1103
Neels Hofmeyrd0b3b9e2019-07-29 19:28:08 +02001104/* logp (<categories>) (debug|...|fatal) .LOGMESSAGE*/
1105DEFUN(vty_logp,
1106 vty_logp_cmd,
1107 NULL, /* cmdstr is dynamically set in gen_vty_logp_cmd_strs(). */
1108 NULL) /* same thing for helpstr. */
1109{
1110 int category = log_parse_category(argv[0]);
1111 int level = log_parse_level(argv[1]);
1112 char *str = argv_concat(argv, argc, 2);
1113 LOGP(category, level, "%s\n", str);
1114 return CMD_SUCCESS;
1115}
1116
1117static void gen_vty_logp_cmd_strs(struct cmd_element *cmd)
1118{
1119 char *cmd_str = NULL;
1120 char *doc_str = NULL;
1121
1122 assert_loginfo(__func__);
1123
1124 OSMO_ASSERT(cmd->string == NULL);
1125 OSMO_ASSERT(cmd->doc == NULL);
1126
1127 osmo_talloc_asprintf(tall_log_ctx, cmd_str, "logp (");
1128 osmo_talloc_asprintf(tall_log_ctx, doc_str,
1129 "Print a message on all log outputs; useful for placing markers in test logs\n");
1130 add_category_strings(&cmd_str, &doc_str, osmo_log_info);
1131 osmo_talloc_asprintf(tall_log_ctx, cmd_str, ") %s", LOG_LEVEL_ARGS);
1132 osmo_talloc_asprintf(tall_log_ctx, doc_str, "%s", LOG_LEVEL_STRS);
1133
1134 osmo_talloc_asprintf(tall_log_ctx, cmd_str, " .LOGMESSAGE");
1135 osmo_talloc_asprintf(tall_log_ctx, doc_str,
1136 "Arbitrary message to log on given category and log level\n");
1137
Harald Weltebebec212020-07-15 12:21:29 +02001138 talloc_set_name_const(cmd_str, "vty_logp_cmd_str");
1139 talloc_set_name_const(doc_str, "vty_logp_doc_str");
1140
Neels Hofmeyrd0b3b9e2019-07-29 19:28:08 +02001141 cmd->string = cmd_str;
1142 cmd->doc = doc_str;
1143}
1144
Harald Welte8c648252017-10-16 15:17:03 +02001145/*! Register logging related commands to the VTY. Call this once from
1146 * your application if you want to support those commands. */
Maxc65c5b42017-03-15 13:20:23 +01001147void logging_vty_add_cmds()
Harald Welte3fb0b6f2010-05-19 19:02:52 +02001148{
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001149 install_lib_element_ve(&enable_logging_cmd);
1150 install_lib_element_ve(&disable_logging_cmd);
1151 install_lib_element_ve(&logging_fltr_all_cmd);
1152 install_lib_element_ve(&logging_use_clr_cmd);
1153 install_lib_element_ve(&logging_prnt_timestamp_cmd);
1154 install_lib_element_ve(&logging_prnt_ext_timestamp_cmd);
Pau Espin Pedrol662d10d2021-02-18 18:19:23 +01001155 install_lib_element_ve(&logging_prnt_tid_cmd);
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001156 install_lib_element_ve(&logging_prnt_cat_cmd);
1157 install_lib_element_ve(&logging_prnt_cat_hex_cmd);
1158 install_lib_element_ve(&logging_prnt_level_cmd);
1159 install_lib_element_ve(&logging_prnt_file_cmd);
1160 install_lib_element_ve(&logging_set_category_mask_cmd);
1161 install_lib_element_ve(&logging_set_category_mask_old_cmd);
Pablo Neira Ayuso04139f12011-03-09 13:05:08 +01001162
Neels Hofmeyr9540c242018-09-12 00:20:50 +02001163 /* logging level (<categories>) (debug|...|fatal) */
Neels Hofmeyrba0762d2018-09-10 13:56:03 +02001164 gen_logging_level_cmd_strs(&logging_level_cmd,
Neels Hofmeyr9540c242018-09-12 00:20:50 +02001165 LOG_LEVEL_ARGS,
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +02001166 LOG_LEVEL_STRS);
Neels Hofmeyr9540c242018-09-12 00:20:50 +02001167 /* logging level (<categories>) everything */
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +02001168 gen_logging_level_cmd_strs(&deprecated_logging_level_everything_cmd,
1169 "everything", EVERYTHING_STR);
Neels Hofmeyrba0762d2018-09-10 13:56:03 +02001170
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001171 install_lib_element_ve(&logging_level_cmd);
1172 install_lib_element_ve(&logging_level_set_all_cmd);
1173 install_lib_element_ve(&logging_level_force_all_cmd);
1174 install_lib_element_ve(&no_logging_level_force_all_cmd);
1175 install_lib_element_ve(&deprecated_logging_level_everything_cmd);
1176 install_lib_element_ve(&deprecated_logging_level_all_cmd);
1177 install_lib_element_ve(&deprecated_logging_level_all_everything_cmd);
Harald Welte28222962011-02-18 20:37:04 +01001178
Neels Hofmeyrd0b3b9e2019-07-29 19:28:08 +02001179 gen_vty_logp_cmd_strs(&vty_logp_cmd);
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001180 install_lib_element_ve(&vty_logp_cmd);
Neels Hofmeyrd0b3b9e2019-07-29 19:28:08 +02001181
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001182 install_lib_element_ve(&show_logging_vty_cmd);
1183 install_lib_element_ve(&show_alarms_cmd);
Pau Espin Pedrol0c2a46d2019-08-20 10:39:05 +02001184
Harald Welte28222962011-02-18 20:37:04 +01001185 install_node(&cfg_log_node, config_write_log);
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001186 install_lib_element(CFG_LOG_NODE, &logging_fltr_all_cmd);
1187 install_lib_element(CFG_LOG_NODE, &logging_use_clr_cmd);
1188 install_lib_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd);
1189 install_lib_element(CFG_LOG_NODE, &logging_prnt_ext_timestamp_cmd);
Pau Espin Pedrol662d10d2021-02-18 18:19:23 +01001190 install_lib_element(CFG_LOG_NODE, &logging_prnt_tid_cmd);
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001191 install_lib_element(CFG_LOG_NODE, &logging_prnt_cat_cmd);
1192 install_lib_element(CFG_LOG_NODE, &logging_prnt_cat_hex_cmd);
1193 install_lib_element(CFG_LOG_NODE, &logging_prnt_level_cmd);
1194 install_lib_element(CFG_LOG_NODE, &logging_prnt_file_cmd);
1195 install_lib_element(CFG_LOG_NODE, &logging_level_cmd);
1196 install_lib_element(CFG_LOG_NODE, &logging_level_set_all_cmd);
1197 install_lib_element(CFG_LOG_NODE, &logging_level_force_all_cmd);
1198 install_lib_element(CFG_LOG_NODE, &no_logging_level_force_all_cmd);
1199 install_lib_element(CFG_LOG_NODE, &deprecated_logging_level_everything_cmd);
1200 install_lib_element(CFG_LOG_NODE, &deprecated_logging_level_all_cmd);
1201 install_lib_element(CFG_LOG_NODE, &deprecated_logging_level_all_everything_cmd);
Harald Welte28222962011-02-18 20:37:04 +01001202
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001203 install_lib_element(CONFIG_NODE, &cfg_log_stderr_cmd);
1204 install_lib_element(CONFIG_NODE, &cfg_no_log_stderr_cmd);
1205 install_lib_element(CONFIG_NODE, &cfg_log_file_cmd);
1206 install_lib_element(CONFIG_NODE, &cfg_no_log_file_cmd);
1207 install_lib_element(CONFIG_NODE, &cfg_log_alarms_cmd);
1208 install_lib_element(CONFIG_NODE, &cfg_no_log_alarms_cmd);
Harald Welte28222962011-02-18 20:37:04 +01001209#ifdef HAVE_SYSLOG_H
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001210 install_lib_element(CONFIG_NODE, &cfg_log_syslog_cmd);
1211 install_lib_element(CONFIG_NODE, &cfg_log_syslog_local_cmd);
1212 install_lib_element(CONFIG_NODE, &cfg_no_log_syslog_cmd);
Harald Welte28222962011-02-18 20:37:04 +01001213#endif
Vadim Yanitskiye7bf4352020-09-09 03:36:48 +07001214 install_lib_element(CONFIG_NODE, &cfg_log_systemd_journal_cmd);
1215 install_lib_element(CONFIG_NODE, &cfg_no_log_systemd_journal_cmd);
Vadim Yanitskiy8e7c4962020-10-04 15:37:31 +07001216 install_lib_element(CONFIG_NODE, &cfg_log_gsmtap_cmd);
Harald Welte3fb0b6f2010-05-19 19:02:52 +02001217}