blob: 3b1d8c650011aef3fc061e6c56fe77f970d187b6 [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 Welte3fb0b6f2010-05-19 19:02:52 +020036
37#include <osmocom/vty/command.h>
38#include <osmocom/vty/buffer.h>
39#include <osmocom/vty/vty.h>
40#include <osmocom/vty/telnet_interface.h>
41#include <osmocom/vty/logging.h>
42
Harald Welte28222962011-02-18 20:37:04 +010043#define LOG_STR "Configure logging sub-system\n"
Neels Hofmeyrba0762d2018-09-10 13:56:03 +020044#define LEVEL_STR "Set the log level for a specified category\n"
45
Neels Hofmeyr9540c242018-09-12 00:20:50 +020046#define CATEGORY_ALL_STR "Deprecated alias for 'force-all'\n"
47#define FORCE_ALL_STR \
48 "Globally force all logging categories to a specific level. This is released by the" \
49 " 'no logging level force-all' command. Note: any 'logging level <category> <level>'" \
50 " commands will have no visible effect after this, until the forced level is released.\n"
51#define NO_FORCE_ALL_STR \
52 "Release any globally forced log level set with 'logging level force-all <level>'\n"
Neels Hofmeyrba0762d2018-09-10 13:56:03 +020053
Neels Hofmeyr9540c242018-09-12 00:20:50 +020054#define LOG_LEVEL_ARGS "(debug|info|notice|error|fatal)"
Neels Hofmeyrba0762d2018-09-10 13:56:03 +020055#define LOG_LEVEL_STRS \
56 "Log debug messages and higher levels\n" \
57 "Log informational messages and higher levels\n" \
58 "Log noticeable messages and higher levels\n" \
59 "Log error messages and higher levels\n" \
60 "Log only fatal messages\n"
61
Neels Hofmeyr9540c242018-09-12 00:20:50 +020062#define EVERYTHING_STR "Deprecated alias for 'no logging level force-all'\n"
Harald Welte28222962011-02-18 20:37:04 +010063
Harald Welte8c648252017-10-16 15:17:03 +020064/*! \file logging_vty.c
Neels Hofmeyr87e45502017-06-20 00:17:59 +020065 * Configuration of logging from VTY
Harald Welte96e2a002017-06-12 21:44:18 +020066 *
Harald Welte8c648252017-10-16 15:17:03 +020067 * This module implements
68 * - functions that permit configuration of the libosmocore logging
69 * framework from VTY commands in the configure -> logging node.
70 *
71 * - functions that permit logging *to* a VTY session. Basically each
72 * VTY session gets its own log target, with configurable
73 * per-subsystem log levels. This is performed internally via the
74 * \ref log_target_create_vty function.
75 *
76 * You have to call \ref logging_vty_add_cmds from your application
77 * once to enable both of the above.
78 *
Harald Welte96e2a002017-06-12 21:44:18 +020079 */
80
Harald Welte76e72ab2011-02-17 15:52:39 +010081static void _vty_output(struct log_target *tgt,
82 unsigned int level, const char *line)
Harald Welte3fb0b6f2010-05-19 19:02:52 +020083{
84 struct vty *vty = tgt->tgt_vty.vty;
85 vty_out(vty, "%s", line);
86 /* This is an ugly hack, but there is no easy way... */
87 if (strchr(line, '\n'))
88 vty_out(vty, "\r");
89}
90
91struct log_target *log_target_create_vty(struct vty *vty)
92{
93 struct log_target *target;
94
95 target = log_target_create();
96 if (!target)
97 return NULL;
98
99 target->tgt_vty.vty = vty;
100 target->output = _vty_output;
101 return target;
102}
103
104DEFUN(enable_logging,
105 enable_logging_cmd,
106 "logging enable",
107 LOGGING_STR
108 "Enables logging to this vty\n")
109{
110 struct telnet_connection *conn;
111
112 conn = (struct telnet_connection *) vty->priv;
113 if (conn->dbg) {
114 vty_out(vty, "Logging already enabled.%s", VTY_NEWLINE);
115 return CMD_WARNING;
116 }
117
118 conn->dbg = log_target_create_vty(vty);
119 if (!conn->dbg)
120 return CMD_WARNING;
121
122 log_add_target(conn->dbg);
123 return CMD_SUCCESS;
124}
125
Harald Weltea62648b2011-02-18 21:03:27 +0100126struct log_target *osmo_log_vty2tgt(struct vty *vty)
127{
128 struct telnet_connection *conn;
129
130 if (vty->node == CFG_LOG_NODE)
131 return vty->index;
132
133
134 conn = (struct telnet_connection *) vty->priv;
135 if (!conn->dbg)
136 vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
137
138 return conn->dbg;
139}
140
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200141DEFUN(logging_fltr_all,
142 logging_fltr_all_cmd,
143 "logging filter all (0|1)",
144 LOGGING_STR FILTER_STR
145 "Do you want to log all messages?\n"
146 "Only print messages matched by other filters\n"
147 "Bypass filter and print all messages\n")
148{
Harald Weltea62648b2011-02-18 21:03:27 +0100149 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200150
Harald Weltea62648b2011-02-18 21:03:27 +0100151 if (!tgt)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200152 return CMD_WARNING;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200153
Harald Weltea62648b2011-02-18 21:03:27 +0100154 log_set_all_filter(tgt, atoi(argv[0]));
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200155 return CMD_SUCCESS;
156}
157
158DEFUN(logging_use_clr,
159 logging_use_clr_cmd,
160 "logging color (0|1)",
161 LOGGING_STR "Configure color-printing for log messages\n"
162 "Don't use color for printing messages\n"
163 "Use color for printing messages\n")
164{
Harald Weltea62648b2011-02-18 21:03:27 +0100165 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200166
Harald Weltea62648b2011-02-18 21:03:27 +0100167 if (!tgt)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200168 return CMD_WARNING;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200169
Harald Weltea62648b2011-02-18 21:03:27 +0100170 log_set_use_color(tgt, atoi(argv[0]));
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200171 return CMD_SUCCESS;
172}
173
174DEFUN(logging_prnt_timestamp,
175 logging_prnt_timestamp_cmd,
176 "logging timestamp (0|1)",
177 LOGGING_STR "Configure log message timestamping\n"
178 "Don't prefix each log message\n"
179 "Prefix each log message with current timestamp\n")
180{
Harald Weltea62648b2011-02-18 21:03:27 +0100181 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200182
Harald Weltea62648b2011-02-18 21:03:27 +0100183 if (!tgt)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200184 return CMD_WARNING;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200185
Harald Weltea62648b2011-02-18 21:03:27 +0100186 log_set_print_timestamp(tgt, atoi(argv[0]));
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200187 return CMD_SUCCESS;
188}
189
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100190DEFUN(logging_prnt_ext_timestamp,
191 logging_prnt_ext_timestamp_cmd,
192 "logging print extended-timestamp (0|1)",
193 LOGGING_STR "Log output settings\n"
194 "Configure log message timestamping\n"
195 "Don't prefix each log message\n"
196 "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\n")
197{
198 struct log_target *tgt = osmo_log_vty2tgt(vty);
199
200 if (!tgt)
201 return CMD_WARNING;
202
203 log_set_print_extended_timestamp(tgt, atoi(argv[0]));
204 return CMD_SUCCESS;
205}
206
207DEFUN(logging_prnt_cat,
208 logging_prnt_cat_cmd,
209 "logging print category (0|1)",
210 LOGGING_STR "Log output settings\n"
211 "Configure log message\n"
212 "Don't prefix each log message\n"
213 "Prefix each log message with category/subsystem name\n")
214{
215 struct log_target *tgt = osmo_log_vty2tgt(vty);
216
217 if (!tgt)
218 return CMD_WARNING;
219
220 log_set_print_category(tgt, atoi(argv[0]));
221 return CMD_SUCCESS;
222}
223
Neels Hofmeyrbd7bd392018-01-16 01:52:29 +0100224DEFUN(logging_prnt_cat_hex,
225 logging_prnt_cat_hex_cmd,
226 "logging print category-hex (0|1)",
227 LOGGING_STR "Log output settings\n"
228 "Configure log message\n"
229 "Don't prefix each log message\n"
230 "Prefix each log message with category/subsystem nr in hex ('<000b>')\n")
231{
232 struct log_target *tgt = osmo_log_vty2tgt(vty);
233
234 if (!tgt)
235 return CMD_WARNING;
236
237 log_set_print_category_hex(tgt, atoi(argv[0]));
238 return CMD_SUCCESS;
239}
240
Neels Hofmeyr886e5482018-01-16 01:49:37 +0100241DEFUN(logging_prnt_level,
242 logging_prnt_level_cmd,
243 "logging print level (0|1)",
244 LOGGING_STR "Log output settings\n"
245 "Configure log message\n"
246 "Don't prefix each log message\n"
247 "Prefix each log message with the log level name\n")
248{
249 struct log_target *tgt = osmo_log_vty2tgt(vty);
250
251 if (!tgt)
252 return CMD_WARNING;
253
254 log_set_print_level(tgt, atoi(argv[0]));
255 return CMD_SUCCESS;
256}
257
Neels Hofmeyr22772cc2018-02-06 00:52:08 +0100258static const struct value_string logging_print_file_args[] = {
259 { LOG_FILENAME_NONE, "0" },
260 { LOG_FILENAME_PATH, "1" },
261 { LOG_FILENAME_BASENAME, "basename" },
262 { 0, NULL }
263};
264
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100265DEFUN(logging_prnt_file,
266 logging_prnt_file_cmd,
Neels Hofmeyr77ae45d2018-08-27 20:32:36 +0200267 "logging print file (0|1|basename) [last]",
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100268 LOGGING_STR "Log output settings\n"
269 "Configure log message\n"
270 "Don't prefix each log message\n"
271 "Prefix each log message with the source file and line\n"
Neels Hofmeyr77ae45d2018-08-27 20:32:36 +0200272 "Prefix each log message with the source file's basename (strip leading paths) and line\n"
273 "Log source file info at the end of a log line. If omitted, log source file info just"
274 " before the log text.\n")
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100275{
276 struct log_target *tgt = osmo_log_vty2tgt(vty);
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100277
278 if (!tgt)
279 return CMD_WARNING;
280
Neels Hofmeyr22772cc2018-02-06 00:52:08 +0100281 log_set_print_filename2(tgt, get_string_value(logging_print_file_args, argv[0]));
Neels Hofmeyr77ae45d2018-08-27 20:32:36 +0200282 if (argc > 1)
283 log_set_print_filename_pos(tgt, LOG_FILENAME_POS_LINE_END);
284 else
285 log_set_print_filename_pos(tgt, LOG_FILENAME_POS_HEADER_END);
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100286 return CMD_SUCCESS;
287}
288
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200289static void add_category_strings(char **cmd_str_p, char **doc_str_p,
290 const struct log_info *categories)
291{
292 int i;
293 for (i = 0; i < categories->num_cat; i++) {
294 if (categories->cat[i].name == NULL)
295 continue;
296 /* skip the leading 'D' in each category name, hence '+ 1' */
297 osmo_talloc_asprintf(tall_log_ctx, *cmd_str_p, "%s%s",
298 i ? "|" : "",
299 osmo_str_tolower(categories->cat[i].name + 1));
300 osmo_talloc_asprintf(tall_log_ctx, *doc_str_p, "%s\n",
301 categories->cat[i].description);
302 }
303}
304
305static void gen_logging_level_cmd_strs(struct cmd_element *cmd,
306 const char *level_args, const char *level_strs)
307{
308 char *cmd_str = NULL;
309 char *doc_str = NULL;
310
311 assert_loginfo(__func__);
312
313 OSMO_ASSERT(cmd->string == NULL);
314 OSMO_ASSERT(cmd->doc == NULL);
315
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200316 osmo_talloc_asprintf(tall_log_ctx, cmd_str, "logging level (");
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200317 osmo_talloc_asprintf(tall_log_ctx, doc_str,
318 LOGGING_STR
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200319 LEVEL_STR);
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200320 add_category_strings(&cmd_str, &doc_str, osmo_log_info);
321 osmo_talloc_asprintf(tall_log_ctx, cmd_str, ") %s", level_args);
322 osmo_talloc_asprintf(tall_log_ctx, doc_str, "%s", level_strs);
323
324 cmd->string = cmd_str;
325 cmd->doc = doc_str;
326}
327
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200328/* logging level (<categories>) (debug|...|fatal) */
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200329DEFUN(logging_level,
330 logging_level_cmd,
Pablo Neira Ayuso04139f12011-03-09 13:05:08 +0100331 NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
332 NULL) /* same thing for helpstr. */
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200333{
Harald Weltea62648b2011-02-18 21:03:27 +0100334 int category = log_parse_category(argv[0]);
335 int level = log_parse_level(argv[1]);
336 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200337
Harald Weltea62648b2011-02-18 21:03:27 +0100338 if (!tgt)
339 return CMD_WARNING;
340
341 if (level < 0) {
342 vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200343 return CMD_WARNING;
344 }
345
Harald Weltea62648b2011-02-18 21:03:27 +0100346 if (category < 0) {
347 vty_out(vty, "Invalid category `%s'%s", argv[0], VTY_NEWLINE);
348 return CMD_WARNING;
349 }
350
351 tgt->categories[category].enabled = 1;
352 tgt->categories[category].loglevel = level;
353
354 return CMD_SUCCESS;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200355}
356
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200357/* logging level (<categories>) everything */
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +0200358DEFUN_DEPRECATED(deprecated_logging_level_everything, deprecated_logging_level_everything_cmd,
359 NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */
360 NULL) /* same thing for helpstr. */
361{
362 vty_out(vty, "%% Ignoring deprecated logging level 'everything' keyword%s", VTY_NEWLINE);
363 return CMD_SUCCESS;
364}
365
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200366DEFUN(logging_level_force_all, logging_level_force_all_cmd,
367 "logging level force-all " LOG_LEVEL_ARGS,
368 LOGGING_STR LEVEL_STR FORCE_ALL_STR LOG_LEVEL_STRS)
369{
370 struct log_target *tgt = osmo_log_vty2tgt(vty);
371 int level = log_parse_level(argv[0]);
372 log_set_log_level(tgt, level);
373 return CMD_SUCCESS;
374}
375
376DEFUN(no_logging_level_force_all, no_logging_level_force_all_cmd,
377 "no logging level force-all",
378 NO_STR LOGGING_STR LEVEL_STR NO_FORCE_ALL_STR)
379{
380 struct log_target *tgt = osmo_log_vty2tgt(vty);
381 log_set_log_level(tgt, 0);
382 return CMD_SUCCESS;
383}
384
385/* 'logging level all (debug|...|fatal)' */
386ALIAS_DEPRECATED(logging_level_force_all, deprecated_logging_level_all_cmd,
387 "logging level all " LOG_LEVEL_ARGS,
388 LOGGING_STR LEVEL_STR CATEGORY_ALL_STR LOG_LEVEL_STRS);
389
390/* 'logging level all everything' */
391ALIAS_DEPRECATED(no_logging_level_force_all, deprecated_logging_level_all_everything_cmd,
392 "logging level all everything",
393 LOGGING_STR LEVEL_STR CATEGORY_ALL_STR EVERYTHING_STR);
394
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200395DEFUN(logging_set_category_mask,
396 logging_set_category_mask_cmd,
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200397 "logging set-log-mask MASK",
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200398 LOGGING_STR
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200399 "Set the logmask of this logging target\n"
Neels Hofmeyr84ea2e02017-12-09 05:53:18 +0100400 "List of logging categories to log, e.g. 'abc:mno:xyz'. Available log categories depend on the specific"
401 " application, refer to the 'logging level' command. Optionally add individual log levels like"
402 " 'abc,1:mno,3:xyz,5', where the level numbers are"
403 " " OSMO_STRINGIFY(LOGL_DEBUG) "=" OSMO_STRINGIFY_VAL(LOGL_DEBUG)
404 " " OSMO_STRINGIFY(LOGL_INFO) "=" OSMO_STRINGIFY_VAL(LOGL_INFO)
405 " " OSMO_STRINGIFY(LOGL_NOTICE) "=" OSMO_STRINGIFY_VAL(LOGL_NOTICE)
406 " " OSMO_STRINGIFY(LOGL_ERROR) "=" OSMO_STRINGIFY_VAL(LOGL_ERROR)
407 " " OSMO_STRINGIFY(LOGL_FATAL) "=" OSMO_STRINGIFY_VAL(LOGL_FATAL)
408 "\n")
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200409{
Harald Weltea62648b2011-02-18 21:03:27 +0100410 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200411
Harald Weltea62648b2011-02-18 21:03:27 +0100412 if (!tgt)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200413 return CMD_WARNING;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200414
Harald Weltea62648b2011-02-18 21:03:27 +0100415 log_parse_category_mask(tgt, argv[0]);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200416 return CMD_SUCCESS;
417}
418
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200419ALIAS_DEPRECATED(logging_set_category_mask,
420 logging_set_category_mask_old_cmd,
421 "logging set log mask MASK",
422 LOGGING_STR
423 "Decide which categories to output.\n"
Neels Hofmeyr84ea2e02017-12-09 05:53:18 +0100424 "Log commands\n" "Mask commands\n"
425 "'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 +0200426
427
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200428DEFUN(diable_logging,
429 disable_logging_cmd,
430 "logging disable",
431 LOGGING_STR
432 "Disables logging to this vty\n")
433{
Harald Weltea62648b2011-02-18 21:03:27 +0100434 struct log_target *tgt = osmo_log_vty2tgt(vty);
435 struct telnet_connection *conn = (struct telnet_connection *) vty->priv;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200436
Harald Weltea62648b2011-02-18 21:03:27 +0100437 if (!tgt)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200438 return CMD_WARNING;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200439
Harald Weltea62648b2011-02-18 21:03:27 +0100440 log_del_target(tgt);
441 talloc_free(tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200442 conn->dbg = NULL;
Harald Weltea62648b2011-02-18 21:03:27 +0100443
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200444 return CMD_SUCCESS;
445}
446
447static void vty_print_logtarget(struct vty *vty, const struct log_info *info,
448 const struct log_target *tgt)
449{
450 unsigned int i;
451
452 vty_out(vty, " Global Loglevel: %s%s",
453 log_level_str(tgt->loglevel), VTY_NEWLINE);
454 vty_out(vty, " Use color: %s, Print Timestamp: %s%s",
455 tgt->use_color ? "On" : "Off",
456 tgt->print_timestamp ? "On" : "Off", VTY_NEWLINE);
457
458 vty_out(vty, " Log Level specific information:%s", VTY_NEWLINE);
459
460 for (i = 0; i < info->num_cat; i++) {
461 const struct log_category *cat = &tgt->categories[i];
Daniel Willmann55363a92016-11-15 10:05:51 +0100462 /* Skip categories that were not initialized */
463 if (!info->cat[i].name)
464 continue;
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200465 vty_out(vty, " %-10s %-10s %-8s %s%s",
466 info->cat[i].name+1, log_level_str(cat->loglevel),
467 cat->enabled ? "Enabled" : "Disabled",
468 info->cat[i].description,
469 VTY_NEWLINE);
470 }
Harald Welte6d2d4d62013-03-10 09:53:24 +0000471
472 vty_out(vty, " Log Filter 'ALL': %s%s",
Neels Hofmeyr8b86cd72017-02-23 18:03:28 +0100473 tgt->filter_map & (1 << LOG_FLT_ALL) ? "Enabled" : "Disabled",
Harald Welte6d2d4d62013-03-10 09:53:24 +0000474 VTY_NEWLINE);
475
Harald Weltefb84f322013-06-06 07:33:54 +0200476 /* print application specific filters */
477 if (info->print_fn)
478 info->print_fn(vty, info, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200479}
480
481#define SHOW_LOG_STR "Show current logging configuration\n"
482
483DEFUN(show_logging_vty,
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000484 show_logging_vty_cmd,
485 "show logging vty",
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200486 SHOW_STR SHOW_LOG_STR
487 "Show current logging configuration for this vty\n")
488{
Harald Weltea62648b2011-02-18 21:03:27 +0100489 struct log_target *tgt = osmo_log_vty2tgt(vty);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200490
Harald Weltea62648b2011-02-18 21:03:27 +0100491 if (!tgt)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200492 return CMD_WARNING;
Harald Weltea62648b2011-02-18 21:03:27 +0100493
494 vty_print_logtarget(vty, osmo_log_info, tgt);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200495
496 return CMD_SUCCESS;
497}
498
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000499DEFUN(show_alarms,
500 show_alarms_cmd,
501 "show alarms",
502 SHOW_STR SHOW_LOG_STR
503 "Show the contents of the logging ringbuffer\n")
504{
505 int i, num_alarms;
506 struct osmo_strrb *rb;
507 struct log_target *tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL);
508 if (!tgt) {
509 vty_out(vty, "%% No alarms, run 'log alarms <2-32700>'%s",
510 VTY_NEWLINE);
511 return CMD_WARNING;
512 }
513
514 rb = tgt->tgt_rb.rb;
515 num_alarms = osmo_strrb_elements(rb);
516
517 vty_out(vty, "%% Showing %i alarms%s", num_alarms, VTY_NEWLINE);
518
519 for (i = 0; i < num_alarms; i++)
520 vty_out(vty, "%% %s%s", osmo_strrb_get_nth(rb, i),
521 VTY_NEWLINE);
522
523 return CMD_SUCCESS;
524}
525
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200526gDEFUN(cfg_description, cfg_description_cmd,
527 "description .TEXT",
Thorsten Alteholza81055d2017-03-02 22:13:48 +0100528 "Save human-readable description of the object\n"
Holger Hans Peter Freytherc9b3e062012-07-25 13:02:49 +0200529 "Text until the end of the line\n")
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200530{
531 char **dptr = vty->index_sub;
532
533 if (!dptr) {
534 vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE);
535 return CMD_WARNING;
536 }
537
Holger Hans Peter Freytherff0670e2011-02-24 14:20:41 +0100538 if (*dptr)
539 talloc_free(*dptr);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200540 *dptr = argv_concat(argv, argc, 0);
Holger Hans Peter Freyther6a75d162013-07-14 09:07:11 +0200541 if (!*dptr)
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200542 return CMD_WARNING;
543
544 return CMD_SUCCESS;
545}
546
547gDEFUN(cfg_no_description, cfg_no_description_cmd,
548 "no description",
549 NO_STR
550 "Remove description of the object\n")
551{
552 char **dptr = vty->index_sub;
553
554 if (!dptr) {
555 vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE);
556 return CMD_WARNING;
557 }
558
559 if (*dptr) {
560 talloc_free(*dptr);
561 *dptr = NULL;
562 }
563
564 return CMD_SUCCESS;
565}
566
Harald Welte28222962011-02-18 20:37:04 +0100567/* Support for configuration of log targets != the current vty */
568
569struct cmd_node cfg_log_node = {
570 CFG_LOG_NODE,
571 "%s(config-log)# ",
572 1
573};
574
Harald Welte28222962011-02-18 20:37:04 +0100575#ifdef HAVE_SYSLOG_H
576
577#include <syslog.h>
578
579static const int local_sysl_map[] = {
580 [0] = LOG_LOCAL0,
581 [1] = LOG_LOCAL1,
582 [2] = LOG_LOCAL2,
583 [3] = LOG_LOCAL3,
584 [4] = LOG_LOCAL4,
585 [5] = LOG_LOCAL5,
586 [6] = LOG_LOCAL6,
587 [7] = LOG_LOCAL7
588};
589
Harald Weltede79cee2011-02-24 23:47:57 +0100590/* From VTY core code */
591extern struct host host;
592
Harald Welte28222962011-02-18 20:37:04 +0100593static int _cfg_log_syslog(struct vty *vty, int facility)
594{
595 struct log_target *tgt;
596
597 /* First delete the old syslog target, if any */
598 tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL);
599 if (tgt)
600 log_target_destroy(tgt);
601
Harald Weltede79cee2011-02-24 23:47:57 +0100602 tgt = log_target_create_syslog(host.app_info->name, 0, facility);
Harald Welte28222962011-02-18 20:37:04 +0100603 if (!tgt) {
604 vty_out(vty, "%% Unable to open syslog%s", VTY_NEWLINE);
605 return CMD_WARNING;
606 }
607 log_add_target(tgt);
608
609 vty->index = tgt;
610 vty->node = CFG_LOG_NODE;
611
612 return CMD_SUCCESS;
613}
614
615DEFUN(cfg_log_syslog_local, cfg_log_syslog_local_cmd,
616 "log syslog local <0-7>",
617 LOG_STR "Logging via syslog\n" "Syslog LOCAL facility\n"
618 "Local facility number\n")
619{
620 int local = atoi(argv[0]);
621 int facility = local_sysl_map[local];
622
623 return _cfg_log_syslog(vty, facility);
624}
625
626static struct value_string sysl_level_names[] = {
627 { LOG_AUTHPRIV, "authpriv" },
628 { LOG_CRON, "cron" },
629 { LOG_DAEMON, "daemon" },
630 { LOG_FTP, "ftp" },
631 { LOG_LPR, "lpr" },
632 { LOG_MAIL, "mail" },
633 { LOG_NEWS, "news" },
634 { LOG_USER, "user" },
635 { LOG_UUCP, "uucp" },
636 /* only for value -> string conversion */
637 { LOG_LOCAL0, "local 0" },
638 { LOG_LOCAL1, "local 1" },
639 { LOG_LOCAL2, "local 2" },
640 { LOG_LOCAL3, "local 3" },
641 { LOG_LOCAL4, "local 4" },
642 { LOG_LOCAL5, "local 5" },
643 { LOG_LOCAL6, "local 6" },
644 { LOG_LOCAL7, "local 7" },
645 { 0, NULL }
646};
647
648DEFUN(cfg_log_syslog, cfg_log_syslog_cmd,
649 "log syslog (authpriv|cron|daemon|ftp|lpr|mail|news|user|uucp)",
Holger Hans Peter Freythera4463fd2011-10-03 23:17:36 +0200650 LOG_STR "Logging via syslog\n"
651 "Security/authorization messages facility\n"
652 "Clock daemon (cron/at) facility\n"
653 "General system daemon facility\n"
654 "Ftp daemon facility\n"
655 "Line printer facility\n"
656 "Mail facility\n"
657 "News facility\n"
658 "Generic facility\n"
659 "UUCP facility\n")
Harald Welte28222962011-02-18 20:37:04 +0100660{
661 int facility = get_string_value(sysl_level_names, argv[0]);
662
663 return _cfg_log_syslog(vty, facility);
664}
665
666DEFUN(cfg_no_log_syslog, cfg_no_log_syslog_cmd,
667 "no log syslog",
668 NO_STR LOG_STR "Logging via syslog\n")
669{
670 struct log_target *tgt;
671
672 tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL);
673 if (!tgt) {
674 vty_out(vty, "%% No syslog target found%s",
675 VTY_NEWLINE);
676 return CMD_WARNING;
677 }
678
679 log_target_destroy(tgt);
680
681 return CMD_SUCCESS;
682}
683#endif /* HAVE_SYSLOG_H */
684
Harald Welteaa00f992016-12-02 15:30:02 +0100685DEFUN(cfg_log_gsmtap, cfg_log_gsmtap_cmd,
686 "log gsmtap [HOSTNAME]",
Neels Hofmeyrfd9ec3b2016-12-11 01:48:26 +0100687 LOG_STR "Logging via GSMTAP\n"
688 "Host name to send the GSMTAP logging to (UDP port 4729)\n")
Harald Welteaa00f992016-12-02 15:30:02 +0100689{
Max2f153b52018-01-04 12:25:57 +0100690 const char *hostname = argc ? argv[0] : "127.0.0.1";
Harald Welteaa00f992016-12-02 15:30:02 +0100691 struct log_target *tgt;
692
693 tgt = log_target_find(LOG_TGT_TYPE_GSMTAP, hostname);
694 if (!tgt) {
695 tgt = log_target_create_gsmtap(hostname, GSMTAP_UDP_PORT,
696 host.app_info->name, false,
697 true);
698 if (!tgt) {
Max2f153b52018-01-04 12:25:57 +0100699 vty_out(vty, "%% Unable to create GSMTAP log for %s%s",
700 hostname, VTY_NEWLINE);
Harald Welteaa00f992016-12-02 15:30:02 +0100701 return CMD_WARNING;
702 }
703 log_add_target(tgt);
704 }
705
706 vty->index = tgt;
707 vty->node = CFG_LOG_NODE;
708
709 return CMD_SUCCESS;
710}
711
Harald Welte28222962011-02-18 20:37:04 +0100712DEFUN(cfg_log_stderr, cfg_log_stderr_cmd,
713 "log stderr",
714 LOG_STR "Logging via STDERR of the process\n")
715{
716 struct log_target *tgt;
717
718 tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL);
719 if (!tgt) {
720 tgt = log_target_create_stderr();
721 if (!tgt) {
722 vty_out(vty, "%% Unable to create stderr log%s",
723 VTY_NEWLINE);
724 return CMD_WARNING;
725 }
726 log_add_target(tgt);
727 }
728
729 vty->index = tgt;
730 vty->node = CFG_LOG_NODE;
731
732 return CMD_SUCCESS;
733}
734
735DEFUN(cfg_no_log_stderr, cfg_no_log_stderr_cmd,
736 "no log stderr",
737 NO_STR LOG_STR "Logging via STDERR of the process\n")
738{
739 struct log_target *tgt;
740
741 tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL);
742 if (!tgt) {
743 vty_out(vty, "%% No stderr logging active%s", VTY_NEWLINE);
744 return CMD_WARNING;
745 }
746
747 log_target_destroy(tgt);
748
749 return CMD_SUCCESS;
750}
751
752DEFUN(cfg_log_file, cfg_log_file_cmd,
753 "log file .FILENAME",
754 LOG_STR "Logging to text file\n" "Filename\n")
755{
756 const char *fname = argv[0];
757 struct log_target *tgt;
758
759 tgt = log_target_find(LOG_TGT_TYPE_FILE, fname);
760 if (!tgt) {
761 tgt = log_target_create_file(fname);
762 if (!tgt) {
763 vty_out(vty, "%% Unable to create file `%s'%s",
764 fname, VTY_NEWLINE);
765 return CMD_WARNING;
766 }
767 log_add_target(tgt);
768 }
769
770 vty->index = tgt;
771 vty->node = CFG_LOG_NODE;
772
773 return CMD_SUCCESS;
774}
775
776
777DEFUN(cfg_no_log_file, cfg_no_log_file_cmd,
778 "no log file .FILENAME",
779 NO_STR LOG_STR "Logging to text file\n" "Filename\n")
780{
781 const char *fname = argv[0];
782 struct log_target *tgt;
783
784 tgt = log_target_find(LOG_TGT_TYPE_FILE, fname);
785 if (!tgt) {
786 vty_out(vty, "%% No such log file `%s'%s",
787 fname, VTY_NEWLINE);
788 return CMD_WARNING;
789 }
790
791 log_target_destroy(tgt);
792
793 return CMD_SUCCESS;
794}
795
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000796DEFUN(cfg_log_alarms, cfg_log_alarms_cmd,
797 "log alarms <2-32700>",
798 LOG_STR "Logging alarms to osmo_strrb\n"
799 "Maximum number of messages to log\n")
800{
801 struct log_target *tgt;
802 unsigned int rbsize = atoi(argv[0]);
803
804 tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL);
805 if (tgt)
806 log_target_destroy(tgt);
807
808 tgt = log_target_create_rb(rbsize);
809 if (!tgt) {
810 vty_out(vty, "%% Unable to create osmo_strrb (size %u)%s",
811 rbsize, VTY_NEWLINE);
812 return CMD_WARNING;
813 }
814 log_add_target(tgt);
815
816 vty->index = tgt;
817 vty->node = CFG_LOG_NODE;
818
819 return CMD_SUCCESS;
820}
821
822DEFUN(cfg_no_log_alarms, cfg_no_log_alarms_cmd,
823 "no log alarms",
824 NO_STR LOG_STR "Logging alarms to osmo_strrb\n")
825{
826 struct log_target *tgt;
827
828 tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL);
829 if (!tgt) {
830 vty_out(vty, "%% No osmo_strrb target found%s", VTY_NEWLINE);
831 return CMD_WARNING;
832 }
833
834 log_target_destroy(tgt);
835
836 return CMD_SUCCESS;
837}
838
Harald Welte28222962011-02-18 20:37:04 +0100839static int config_write_log_single(struct vty *vty, struct log_target *tgt)
840{
841 int i;
Harald Welte28222962011-02-18 20:37:04 +0100842
843 switch (tgt->type) {
844 case LOG_TGT_TYPE_VTY:
845 return 1;
846 break;
847 case LOG_TGT_TYPE_STDERR:
848 vty_out(vty, "log stderr%s", VTY_NEWLINE);
849 break;
850 case LOG_TGT_TYPE_SYSLOG:
851#ifdef HAVE_SYSLOG_H
852 vty_out(vty, "log syslog %s%s",
853 get_value_string(sysl_level_names,
854 tgt->tgt_syslog.facility),
855 VTY_NEWLINE);
856#endif
857 break;
858 case LOG_TGT_TYPE_FILE:
859 vty_out(vty, "log file %s%s", tgt->tgt_file.fname, VTY_NEWLINE);
860 break;
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000861 case LOG_TGT_TYPE_STRRB:
862 vty_out(vty, "log alarms %zu%s",
863 log_target_rb_avail_size(tgt), VTY_NEWLINE);
864 break;
Harald Welteaa00f992016-12-02 15:30:02 +0100865 case LOG_TGT_TYPE_GSMTAP:
866 vty_out(vty, "log gsmtap %s%s",
867 tgt->tgt_gsmtap.hostname, VTY_NEWLINE);
868 break;
Harald Welte28222962011-02-18 20:37:04 +0100869 }
870
Harald Welte2da47f12012-10-22 19:31:54 +0200871 vty_out(vty, " logging filter all %u%s",
Neels Hofmeyr8b86cd72017-02-23 18:03:28 +0100872 tgt->filter_map & (1 << LOG_FLT_ALL) ? 1 : 0, VTY_NEWLINE);
Harald Weltefb84f322013-06-06 07:33:54 +0200873 /* save filters outside of libosmocore, i.e. in app code */
874 if (osmo_log_info->save_fn)
875 osmo_log_info->save_fn(vty, osmo_log_info, tgt);
Harald Welte2da47f12012-10-22 19:31:54 +0200876
Harald Welte28222962011-02-18 20:37:04 +0100877 vty_out(vty, " logging color %u%s", tgt->use_color ? 1 : 0,
878 VTY_NEWLINE);
Holger Hans Peter Freyther879acef2015-01-27 11:06:51 +0100879 vty_out(vty, " logging print category %d%s",
Michael McTernan78933462015-03-20 15:29:25 +0100880 tgt->print_category ? 1 : 0, VTY_NEWLINE);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100881 if (tgt->print_ext_timestamp)
882 vty_out(vty, " logging print extended-timestamp 1%s", VTY_NEWLINE);
883 else
884 vty_out(vty, " logging timestamp %u%s",
885 tgt->print_timestamp ? 1 : 0, VTY_NEWLINE);
Neels Hofmeyr886e5482018-01-16 01:49:37 +0100886 if (tgt->print_level)
887 vty_out(vty, " logging print level 1%s", VTY_NEWLINE);
Neels Hofmeyr22772cc2018-02-06 00:52:08 +0100888 vty_out(vty, " logging print file %s%s",
889 get_value_string(logging_print_file_args, tgt->print_filename2),
890 VTY_NEWLINE);
Harald Welte28222962011-02-18 20:37:04 +0100891
Neels Hofmeyr098038a2018-09-11 23:49:13 +0200892 if (tgt->loglevel) {
893 const char *level_str = get_value_string_or_null(loglevel_strs, tgt->loglevel);
894 level_str = osmo_str_tolower(level_str);
895 if (!level_str)
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200896 vty_out(vty, "%% Invalid log level %u for 'force-all'%s",
897 tgt->loglevel, VTY_NEWLINE);
Neels Hofmeyr098038a2018-09-11 23:49:13 +0200898 else
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200899 vty_out(vty, " logging level force-all %s%s", level_str, VTY_NEWLINE);
Neels Hofmeyr098038a2018-09-11 23:49:13 +0200900 }
Harald Welte28222962011-02-18 20:37:04 +0100901
902 for (i = 0; i < osmo_log_info->num_cat; i++) {
903 const struct log_category *cat = &tgt->categories[i];
Neels Hofmeyr098038a2018-09-11 23:49:13 +0200904 const char *cat_name;
905 const char *level_str;
Harald Welte28222962011-02-18 20:37:04 +0100906
Harald Welte1a02cfc2013-03-19 10:37:39 +0100907 /* skip empty entries in the array */
908 if (!osmo_log_info->cat[i].name)
909 continue;
910
Neels Hofmeyr098038a2018-09-11 23:49:13 +0200911 /* Note: cat_name references the static buffer returned by osmo_str_tolower(), will
912 * become invalid after next osmo_str_tolower() invocation. */
913 cat_name = osmo_str_tolower(osmo_log_info->cat[i].name+1);
914
915 level_str = get_value_string_or_null(loglevel_strs, cat->loglevel);
916 if (!level_str) {
917 vty_out(vty, "%% Invalid log level %u for %s%s", cat->loglevel, cat_name,
918 VTY_NEWLINE);
919 continue;
920 }
921
922 vty_out(vty, " logging level %s", cat_name);
923 vty_out(vty, " %s%s", osmo_str_tolower(level_str), VTY_NEWLINE);
Harald Welte28222962011-02-18 20:37:04 +0100924 }
925
Harald Welte28222962011-02-18 20:37:04 +0100926 return 1;
927}
928
929static int config_write_log(struct vty *vty)
930{
931 struct log_target *dbg = vty->index;
932
933 llist_for_each_entry(dbg, &osmo_log_target_list, entry)
934 config_write_log_single(vty, dbg);
935
936 return 1;
937}
938
Harald Welte11eb4b52018-06-09 17:41:31 +0200939static int log_deprecated_func(struct cmd_element *cmd, struct vty *vty, int argc, const char *argv[])
940{
941 vty_out(vty, "%% Ignoring deprecated '%s'%s", cmd->string, VTY_NEWLINE);
942 return CMD_WARNING;
943}
944
945void logging_vty_add_deprecated_subsys(void *ctx, const char *name)
946{
947 struct cmd_element *cmd = talloc_zero(ctx, struct cmd_element);
948 OSMO_ASSERT(cmd);
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +0200949 cmd->string = talloc_asprintf(cmd, "logging level %s (debug|info|notice|error|fatal)",
Harald Welte11eb4b52018-06-09 17:41:31 +0200950 name);
951 printf("%s\n", cmd->string);
952 cmd->func = log_deprecated_func;
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200953 cmd->doc = LEVEL_STR
Harald Welte11eb4b52018-06-09 17:41:31 +0200954 "Deprecated Category\n";
955 cmd->attr = CMD_ATTR_DEPRECATED;
956
957 install_element(CFG_LOG_NODE, cmd);
958}
959
Harald Welte8c648252017-10-16 15:17:03 +0200960/*! Register logging related commands to the VTY. Call this once from
961 * your application if you want to support those commands. */
Maxc65c5b42017-03-15 13:20:23 +0100962void logging_vty_add_cmds()
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200963{
964 install_element_ve(&enable_logging_cmd);
965 install_element_ve(&disable_logging_cmd);
966 install_element_ve(&logging_fltr_all_cmd);
967 install_element_ve(&logging_use_clr_cmd);
968 install_element_ve(&logging_prnt_timestamp_cmd);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100969 install_element_ve(&logging_prnt_ext_timestamp_cmd);
970 install_element_ve(&logging_prnt_cat_cmd);
Neels Hofmeyrbd7bd392018-01-16 01:52:29 +0100971 install_element_ve(&logging_prnt_cat_hex_cmd);
Neels Hofmeyr886e5482018-01-16 01:49:37 +0100972 install_element_ve(&logging_prnt_level_cmd);
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +0100973 install_element_ve(&logging_prnt_file_cmd);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200974 install_element_ve(&logging_set_category_mask_cmd);
Holger Hans Peter Freyther146d1d32011-10-03 23:15:41 +0200975 install_element_ve(&logging_set_category_mask_old_cmd);
Pablo Neira Ayuso04139f12011-03-09 13:05:08 +0100976
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200977 /* logging level (<categories>) (debug|...|fatal) */
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200978 gen_logging_level_cmd_strs(&logging_level_cmd,
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200979 LOG_LEVEL_ARGS,
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +0200980 LOG_LEVEL_STRS);
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200981 /* logging level (<categories>) everything */
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +0200982 gen_logging_level_cmd_strs(&deprecated_logging_level_everything_cmd,
983 "everything", EVERYTHING_STR);
Neels Hofmeyrba0762d2018-09-10 13:56:03 +0200984
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200985 install_element_ve(&logging_level_cmd);
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200986 install_element_ve(&logging_level_force_all_cmd);
987 install_element_ve(&no_logging_level_force_all_cmd);
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +0200988 install_element_ve(&deprecated_logging_level_everything_cmd);
Neels Hofmeyr9540c242018-09-12 00:20:50 +0200989 install_element_ve(&deprecated_logging_level_all_cmd);
990 install_element_ve(&deprecated_logging_level_all_everything_cmd);
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200991 install_element_ve(&show_logging_vty_cmd);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +0000992 install_element_ve(&show_alarms_cmd);
Harald Welte28222962011-02-18 20:37:04 +0100993
994 install_node(&cfg_log_node, config_write_log);
Harald Weltea62648b2011-02-18 21:03:27 +0100995 install_element(CFG_LOG_NODE, &logging_fltr_all_cmd);
996 install_element(CFG_LOG_NODE, &logging_use_clr_cmd);
997 install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd);
Holger Hans Peter Freyther2d6ad132014-12-05 09:35:30 +0100998 install_element(CFG_LOG_NODE, &logging_prnt_ext_timestamp_cmd);
999 install_element(CFG_LOG_NODE, &logging_prnt_cat_cmd);
Neels Hofmeyrbd7bd392018-01-16 01:52:29 +01001000 install_element(CFG_LOG_NODE, &logging_prnt_cat_hex_cmd);
Neels Hofmeyr886e5482018-01-16 01:49:37 +01001001 install_element(CFG_LOG_NODE, &logging_prnt_level_cmd);
Neels Hofmeyrc6fd2452018-01-16 01:57:38 +01001002 install_element(CFG_LOG_NODE, &logging_prnt_file_cmd);
Harald Weltea62648b2011-02-18 21:03:27 +01001003 install_element(CFG_LOG_NODE, &logging_level_cmd);
Neels Hofmeyr9540c242018-09-12 00:20:50 +02001004 install_element(CFG_LOG_NODE, &logging_level_force_all_cmd);
1005 install_element(CFG_LOG_NODE, &no_logging_level_force_all_cmd);
Neels Hofmeyr7e0686c2018-09-10 20:58:52 +02001006 install_element(CFG_LOG_NODE, &deprecated_logging_level_everything_cmd);
Neels Hofmeyr9540c242018-09-12 00:20:50 +02001007 install_element(CFG_LOG_NODE, &deprecated_logging_level_all_cmd);
1008 install_element(CFG_LOG_NODE, &deprecated_logging_level_all_everything_cmd);
Harald Welte28222962011-02-18 20:37:04 +01001009
1010 install_element(CONFIG_NODE, &cfg_log_stderr_cmd);
1011 install_element(CONFIG_NODE, &cfg_no_log_stderr_cmd);
1012 install_element(CONFIG_NODE, &cfg_log_file_cmd);
1013 install_element(CONFIG_NODE, &cfg_no_log_file_cmd);
Katerina Barone-Adesi3309a432013-02-21 05:16:29 +00001014 install_element(CONFIG_NODE, &cfg_log_alarms_cmd);
1015 install_element(CONFIG_NODE, &cfg_no_log_alarms_cmd);
Harald Welte28222962011-02-18 20:37:04 +01001016#ifdef HAVE_SYSLOG_H
1017 install_element(CONFIG_NODE, &cfg_log_syslog_cmd);
1018 install_element(CONFIG_NODE, &cfg_log_syslog_local_cmd);
1019 install_element(CONFIG_NODE, &cfg_no_log_syslog_cmd);
1020#endif
Harald Welteaa00f992016-12-02 15:30:02 +01001021 install_element(CONFIG_NODE, &cfg_log_gsmtap_cmd);
Harald Welte3fb0b6f2010-05-19 19:02:52 +02001022}