Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 3 | * (C) 2009-2014 by Holger Hans Peter Freyther |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 4 | * All Rights Reserved |
| 5 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | * |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 8 | * 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 Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 27 | #include "../../config.h" |
| 28 | |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 29 | #include <osmocom/core/talloc.h> |
| 30 | #include <osmocom/core/logging.h> |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 31 | #include <osmocom/core/logging_internal.h> |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 32 | #include <osmocom/core/utils.h> |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 33 | #include <osmocom/core/strrb.h> |
| 34 | #include <osmocom/core/loggingrb.h> |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 35 | #include <osmocom/core/gsmtap.h> |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 36 | |
| 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 Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 43 | #define LOG_STR "Configure logging sub-system\n" |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 44 | #define LEVEL_STR "Set the log level for a specified category\n" |
| 45 | |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 46 | #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 Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 53 | |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 54 | #define LOG_LEVEL_ARGS "(debug|info|notice|error|fatal)" |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 55 | #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 Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 62 | #define EVERYTHING_STR "Deprecated alias for 'no logging level force-all'\n" |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 63 | |
Harald Welte | 8c64825 | 2017-10-16 15:17:03 +0200 | [diff] [blame] | 64 | /*! \file logging_vty.c |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 65 | * Configuration of logging from VTY |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 66 | * |
Harald Welte | 8c64825 | 2017-10-16 15:17:03 +0200 | [diff] [blame] | 67 | * 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 Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 79 | */ |
| 80 | |
Harald Welte | 76e72ab | 2011-02-17 15:52:39 +0100 | [diff] [blame] | 81 | static void _vty_output(struct log_target *tgt, |
| 82 | unsigned int level, const char *line) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 83 | { |
| 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 | |
| 91 | struct 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 | |
| 104 | DEFUN(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 Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 126 | struct 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 Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 141 | DEFUN(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 Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 149 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 150 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 151 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 152 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 153 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 154 | log_set_all_filter(tgt, atoi(argv[0])); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 155 | return CMD_SUCCESS; |
| 156 | } |
| 157 | |
| 158 | DEFUN(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 Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 165 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 166 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 167 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 168 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 169 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 170 | log_set_use_color(tgt, atoi(argv[0])); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 171 | return CMD_SUCCESS; |
| 172 | } |
| 173 | |
| 174 | DEFUN(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 Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 181 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 182 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 183 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 184 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 185 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 186 | log_set_print_timestamp(tgt, atoi(argv[0])); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 187 | return CMD_SUCCESS; |
| 188 | } |
| 189 | |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 190 | DEFUN(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 | |
| 207 | DEFUN(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 Hofmeyr | bd7bd39 | 2018-01-16 01:52:29 +0100 | [diff] [blame] | 224 | DEFUN(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 Hofmeyr | 886e548 | 2018-01-16 01:49:37 +0100 | [diff] [blame] | 241 | DEFUN(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 Hofmeyr | 22772cc | 2018-02-06 00:52:08 +0100 | [diff] [blame] | 258 | static 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 Hofmeyr | c6fd245 | 2018-01-16 01:57:38 +0100 | [diff] [blame] | 265 | DEFUN(logging_prnt_file, |
| 266 | logging_prnt_file_cmd, |
Neels Hofmeyr | 77ae45d | 2018-08-27 20:32:36 +0200 | [diff] [blame] | 267 | "logging print file (0|1|basename) [last]", |
Neels Hofmeyr | c6fd245 | 2018-01-16 01:57:38 +0100 | [diff] [blame] | 268 | 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 Hofmeyr | 77ae45d | 2018-08-27 20:32:36 +0200 | [diff] [blame] | 272 | "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 Hofmeyr | c6fd245 | 2018-01-16 01:57:38 +0100 | [diff] [blame] | 275 | { |
| 276 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Neels Hofmeyr | c6fd245 | 2018-01-16 01:57:38 +0100 | [diff] [blame] | 277 | |
| 278 | if (!tgt) |
| 279 | return CMD_WARNING; |
| 280 | |
Neels Hofmeyr | 22772cc | 2018-02-06 00:52:08 +0100 | [diff] [blame] | 281 | log_set_print_filename2(tgt, get_string_value(logging_print_file_args, argv[0])); |
Neels Hofmeyr | 77ae45d | 2018-08-27 20:32:36 +0200 | [diff] [blame] | 282 | 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 Hofmeyr | c6fd245 | 2018-01-16 01:57:38 +0100 | [diff] [blame] | 286 | return CMD_SUCCESS; |
| 287 | } |
| 288 | |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 289 | static void add_category_strings(char **cmd_str_p, char **doc_str_p, |
| 290 | const struct log_info *categories) |
| 291 | { |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 292 | char buf[128]; |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 293 | int i; |
| 294 | for (i = 0; i < categories->num_cat; i++) { |
| 295 | if (categories->cat[i].name == NULL) |
| 296 | continue; |
| 297 | /* skip the leading 'D' in each category name, hence '+ 1' */ |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 298 | osmo_str_tolower_buf(buf, sizeof(buf), categories->cat[i].name + 1); |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 299 | osmo_talloc_asprintf(tall_log_ctx, *cmd_str_p, "%s%s", |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 300 | i ? "|" : "", buf); |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 301 | osmo_talloc_asprintf(tall_log_ctx, *doc_str_p, "%s\n", |
| 302 | categories->cat[i].description); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | static void gen_logging_level_cmd_strs(struct cmd_element *cmd, |
| 307 | const char *level_args, const char *level_strs) |
| 308 | { |
| 309 | char *cmd_str = NULL; |
| 310 | char *doc_str = NULL; |
| 311 | |
| 312 | assert_loginfo(__func__); |
| 313 | |
| 314 | OSMO_ASSERT(cmd->string == NULL); |
| 315 | OSMO_ASSERT(cmd->doc == NULL); |
| 316 | |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 317 | osmo_talloc_asprintf(tall_log_ctx, cmd_str, "logging level ("); |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 318 | osmo_talloc_asprintf(tall_log_ctx, doc_str, |
| 319 | LOGGING_STR |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 320 | LEVEL_STR); |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 321 | add_category_strings(&cmd_str, &doc_str, osmo_log_info); |
| 322 | osmo_talloc_asprintf(tall_log_ctx, cmd_str, ") %s", level_args); |
| 323 | osmo_talloc_asprintf(tall_log_ctx, doc_str, "%s", level_strs); |
| 324 | |
| 325 | cmd->string = cmd_str; |
| 326 | cmd->doc = doc_str; |
| 327 | } |
| 328 | |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 329 | /* logging level (<categories>) (debug|...|fatal) */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 330 | DEFUN(logging_level, |
| 331 | logging_level_cmd, |
Pablo Neira Ayuso | 04139f1 | 2011-03-09 13:05:08 +0100 | [diff] [blame] | 332 | NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */ |
| 333 | NULL) /* same thing for helpstr. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 334 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 335 | int category = log_parse_category(argv[0]); |
| 336 | int level = log_parse_level(argv[1]); |
| 337 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 338 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 339 | if (!tgt) |
| 340 | return CMD_WARNING; |
| 341 | |
| 342 | if (level < 0) { |
| 343 | vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 344 | return CMD_WARNING; |
| 345 | } |
| 346 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 347 | if (category < 0) { |
| 348 | vty_out(vty, "Invalid category `%s'%s", argv[0], VTY_NEWLINE); |
| 349 | return CMD_WARNING; |
| 350 | } |
| 351 | |
| 352 | tgt->categories[category].enabled = 1; |
| 353 | tgt->categories[category].loglevel = level; |
| 354 | |
| 355 | return CMD_SUCCESS; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 356 | } |
| 357 | |
Neels Hofmeyr | 28fc078 | 2018-09-12 02:32:02 +0200 | [diff] [blame] | 358 | DEFUN(logging_level_set_all, logging_level_set_all_cmd, |
| 359 | "logging level set-all " LOG_LEVEL_ARGS, |
| 360 | LOGGING_STR LEVEL_STR |
| 361 | "Once-off set all categories to the given log level. There is no single command" |
| 362 | " to take back these changes -- each category is set to the given level, period.\n" |
| 363 | LOG_LEVEL_STRS) |
| 364 | { |
| 365 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 366 | int level = log_parse_level(argv[0]); |
| 367 | int i; |
Neels Hofmeyr | ea6f519 | 2018-10-01 15:51:18 +0200 | [diff] [blame] | 368 | |
| 369 | if (!tgt) |
| 370 | return CMD_WARNING; |
| 371 | |
Neels Hofmeyr | 28fc078 | 2018-09-12 02:32:02 +0200 | [diff] [blame] | 372 | for (i = 0; i < osmo_log_info->num_cat; i++) { |
| 373 | struct log_category *cat = &tgt->categories[i]; |
| 374 | /* skip empty entries in the array */ |
| 375 | if (!osmo_log_info->cat[i].name) |
| 376 | continue; |
| 377 | |
| 378 | cat->enabled = 1; |
| 379 | cat->loglevel = level; |
| 380 | } |
| 381 | return CMD_SUCCESS; |
| 382 | } |
| 383 | |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 384 | /* logging level (<categories>) everything */ |
Neels Hofmeyr | 7e0686c | 2018-09-10 20:58:52 +0200 | [diff] [blame] | 385 | DEFUN_DEPRECATED(deprecated_logging_level_everything, deprecated_logging_level_everything_cmd, |
| 386 | NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */ |
| 387 | NULL) /* same thing for helpstr. */ |
| 388 | { |
| 389 | vty_out(vty, "%% Ignoring deprecated logging level 'everything' keyword%s", VTY_NEWLINE); |
| 390 | return CMD_SUCCESS; |
| 391 | } |
| 392 | |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 393 | DEFUN(logging_level_force_all, logging_level_force_all_cmd, |
| 394 | "logging level force-all " LOG_LEVEL_ARGS, |
| 395 | LOGGING_STR LEVEL_STR FORCE_ALL_STR LOG_LEVEL_STRS) |
| 396 | { |
| 397 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 398 | int level = log_parse_level(argv[0]); |
Neels Hofmeyr | ea6f519 | 2018-10-01 15:51:18 +0200 | [diff] [blame] | 399 | if (!tgt) |
| 400 | return CMD_WARNING; |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 401 | log_set_log_level(tgt, level); |
| 402 | return CMD_SUCCESS; |
| 403 | } |
| 404 | |
| 405 | DEFUN(no_logging_level_force_all, no_logging_level_force_all_cmd, |
| 406 | "no logging level force-all", |
| 407 | NO_STR LOGGING_STR LEVEL_STR NO_FORCE_ALL_STR) |
| 408 | { |
| 409 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Neels Hofmeyr | ea6f519 | 2018-10-01 15:51:18 +0200 | [diff] [blame] | 410 | if (!tgt) |
| 411 | return CMD_WARNING; |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 412 | log_set_log_level(tgt, 0); |
| 413 | return CMD_SUCCESS; |
| 414 | } |
| 415 | |
| 416 | /* 'logging level all (debug|...|fatal)' */ |
| 417 | ALIAS_DEPRECATED(logging_level_force_all, deprecated_logging_level_all_cmd, |
| 418 | "logging level all " LOG_LEVEL_ARGS, |
| 419 | LOGGING_STR LEVEL_STR CATEGORY_ALL_STR LOG_LEVEL_STRS); |
| 420 | |
| 421 | /* 'logging level all everything' */ |
| 422 | ALIAS_DEPRECATED(no_logging_level_force_all, deprecated_logging_level_all_everything_cmd, |
| 423 | "logging level all everything", |
| 424 | LOGGING_STR LEVEL_STR CATEGORY_ALL_STR EVERYTHING_STR); |
| 425 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 426 | DEFUN(logging_set_category_mask, |
| 427 | logging_set_category_mask_cmd, |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 428 | "logging set-log-mask MASK", |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 429 | LOGGING_STR |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 430 | "Set the logmask of this logging target\n" |
Neels Hofmeyr | 84ea2e0 | 2017-12-09 05:53:18 +0100 | [diff] [blame] | 431 | "List of logging categories to log, e.g. 'abc:mno:xyz'. Available log categories depend on the specific" |
| 432 | " application, refer to the 'logging level' command. Optionally add individual log levels like" |
| 433 | " 'abc,1:mno,3:xyz,5', where the level numbers are" |
| 434 | " " OSMO_STRINGIFY(LOGL_DEBUG) "=" OSMO_STRINGIFY_VAL(LOGL_DEBUG) |
| 435 | " " OSMO_STRINGIFY(LOGL_INFO) "=" OSMO_STRINGIFY_VAL(LOGL_INFO) |
| 436 | " " OSMO_STRINGIFY(LOGL_NOTICE) "=" OSMO_STRINGIFY_VAL(LOGL_NOTICE) |
| 437 | " " OSMO_STRINGIFY(LOGL_ERROR) "=" OSMO_STRINGIFY_VAL(LOGL_ERROR) |
| 438 | " " OSMO_STRINGIFY(LOGL_FATAL) "=" OSMO_STRINGIFY_VAL(LOGL_FATAL) |
| 439 | "\n") |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 440 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 441 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 442 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 443 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 444 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 445 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 446 | log_parse_category_mask(tgt, argv[0]); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 447 | return CMD_SUCCESS; |
| 448 | } |
| 449 | |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 450 | ALIAS_DEPRECATED(logging_set_category_mask, |
| 451 | logging_set_category_mask_old_cmd, |
| 452 | "logging set log mask MASK", |
| 453 | LOGGING_STR |
| 454 | "Decide which categories to output.\n" |
Neels Hofmeyr | 84ea2e0 | 2017-12-09 05:53:18 +0100 | [diff] [blame] | 455 | "Log commands\n" "Mask commands\n" |
| 456 | "'set log mask' is deprecated, please refer to the docs of 'set-log-mask' instead\n"); |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 457 | |
| 458 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 459 | DEFUN(diable_logging, |
| 460 | disable_logging_cmd, |
| 461 | "logging disable", |
| 462 | LOGGING_STR |
| 463 | "Disables logging to this vty\n") |
| 464 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 465 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 466 | struct telnet_connection *conn = (struct telnet_connection *) vty->priv; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 467 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 468 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 469 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 470 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 471 | log_del_target(tgt); |
| 472 | talloc_free(tgt); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 473 | conn->dbg = NULL; |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 474 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 475 | return CMD_SUCCESS; |
| 476 | } |
| 477 | |
| 478 | static void vty_print_logtarget(struct vty *vty, const struct log_info *info, |
| 479 | const struct log_target *tgt) |
| 480 | { |
| 481 | unsigned int i; |
| 482 | |
| 483 | vty_out(vty, " Global Loglevel: %s%s", |
| 484 | log_level_str(tgt->loglevel), VTY_NEWLINE); |
| 485 | vty_out(vty, " Use color: %s, Print Timestamp: %s%s", |
| 486 | tgt->use_color ? "On" : "Off", |
| 487 | tgt->print_timestamp ? "On" : "Off", VTY_NEWLINE); |
| 488 | |
| 489 | vty_out(vty, " Log Level specific information:%s", VTY_NEWLINE); |
| 490 | |
| 491 | for (i = 0; i < info->num_cat; i++) { |
| 492 | const struct log_category *cat = &tgt->categories[i]; |
Daniel Willmann | 55363a9 | 2016-11-15 10:05:51 +0100 | [diff] [blame] | 493 | /* Skip categories that were not initialized */ |
| 494 | if (!info->cat[i].name) |
| 495 | continue; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 496 | vty_out(vty, " %-10s %-10s %-8s %s%s", |
| 497 | info->cat[i].name+1, log_level_str(cat->loglevel), |
| 498 | cat->enabled ? "Enabled" : "Disabled", |
| 499 | info->cat[i].description, |
| 500 | VTY_NEWLINE); |
| 501 | } |
Harald Welte | 6d2d4d6 | 2013-03-10 09:53:24 +0000 | [diff] [blame] | 502 | |
| 503 | vty_out(vty, " Log Filter 'ALL': %s%s", |
Neels Hofmeyr | 8b86cd7 | 2017-02-23 18:03:28 +0100 | [diff] [blame] | 504 | tgt->filter_map & (1 << LOG_FLT_ALL) ? "Enabled" : "Disabled", |
Harald Welte | 6d2d4d6 | 2013-03-10 09:53:24 +0000 | [diff] [blame] | 505 | VTY_NEWLINE); |
| 506 | |
Harald Welte | fb84f32 | 2013-06-06 07:33:54 +0200 | [diff] [blame] | 507 | /* print application specific filters */ |
| 508 | if (info->print_fn) |
| 509 | info->print_fn(vty, info, tgt); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | #define SHOW_LOG_STR "Show current logging configuration\n" |
| 513 | |
| 514 | DEFUN(show_logging_vty, |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 515 | show_logging_vty_cmd, |
| 516 | "show logging vty", |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 517 | SHOW_STR SHOW_LOG_STR |
| 518 | "Show current logging configuration for this vty\n") |
| 519 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 520 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 521 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 522 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 523 | return CMD_WARNING; |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 524 | |
| 525 | vty_print_logtarget(vty, osmo_log_info, tgt); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 526 | |
| 527 | return CMD_SUCCESS; |
| 528 | } |
| 529 | |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 530 | DEFUN(show_alarms, |
| 531 | show_alarms_cmd, |
| 532 | "show alarms", |
| 533 | SHOW_STR SHOW_LOG_STR |
| 534 | "Show the contents of the logging ringbuffer\n") |
| 535 | { |
| 536 | int i, num_alarms; |
| 537 | struct osmo_strrb *rb; |
| 538 | struct log_target *tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL); |
| 539 | if (!tgt) { |
| 540 | vty_out(vty, "%% No alarms, run 'log alarms <2-32700>'%s", |
| 541 | VTY_NEWLINE); |
| 542 | return CMD_WARNING; |
| 543 | } |
| 544 | |
| 545 | rb = tgt->tgt_rb.rb; |
| 546 | num_alarms = osmo_strrb_elements(rb); |
| 547 | |
| 548 | vty_out(vty, "%% Showing %i alarms%s", num_alarms, VTY_NEWLINE); |
| 549 | |
| 550 | for (i = 0; i < num_alarms; i++) |
| 551 | vty_out(vty, "%% %s%s", osmo_strrb_get_nth(rb, i), |
| 552 | VTY_NEWLINE); |
| 553 | |
| 554 | return CMD_SUCCESS; |
| 555 | } |
| 556 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 557 | gDEFUN(cfg_description, cfg_description_cmd, |
| 558 | "description .TEXT", |
Thorsten Alteholz | a81055d | 2017-03-02 22:13:48 +0100 | [diff] [blame] | 559 | "Save human-readable description of the object\n" |
Holger Hans Peter Freyther | c9b3e06 | 2012-07-25 13:02:49 +0200 | [diff] [blame] | 560 | "Text until the end of the line\n") |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 561 | { |
| 562 | char **dptr = vty->index_sub; |
| 563 | |
| 564 | if (!dptr) { |
| 565 | vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE); |
| 566 | return CMD_WARNING; |
| 567 | } |
| 568 | |
Holger Hans Peter Freyther | ff0670e | 2011-02-24 14:20:41 +0100 | [diff] [blame] | 569 | if (*dptr) |
| 570 | talloc_free(*dptr); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 571 | *dptr = argv_concat(argv, argc, 0); |
Holger Hans Peter Freyther | 6a75d16 | 2013-07-14 09:07:11 +0200 | [diff] [blame] | 572 | if (!*dptr) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 573 | return CMD_WARNING; |
| 574 | |
| 575 | return CMD_SUCCESS; |
| 576 | } |
| 577 | |
| 578 | gDEFUN(cfg_no_description, cfg_no_description_cmd, |
| 579 | "no description", |
| 580 | NO_STR |
| 581 | "Remove description of the object\n") |
| 582 | { |
| 583 | char **dptr = vty->index_sub; |
| 584 | |
| 585 | if (!dptr) { |
| 586 | vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE); |
| 587 | return CMD_WARNING; |
| 588 | } |
| 589 | |
| 590 | if (*dptr) { |
| 591 | talloc_free(*dptr); |
| 592 | *dptr = NULL; |
| 593 | } |
| 594 | |
| 595 | return CMD_SUCCESS; |
| 596 | } |
| 597 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 598 | /* Support for configuration of log targets != the current vty */ |
| 599 | |
| 600 | struct cmd_node cfg_log_node = { |
| 601 | CFG_LOG_NODE, |
| 602 | "%s(config-log)# ", |
| 603 | 1 |
| 604 | }; |
| 605 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 606 | #ifdef HAVE_SYSLOG_H |
| 607 | |
| 608 | #include <syslog.h> |
| 609 | |
| 610 | static const int local_sysl_map[] = { |
| 611 | [0] = LOG_LOCAL0, |
| 612 | [1] = LOG_LOCAL1, |
| 613 | [2] = LOG_LOCAL2, |
| 614 | [3] = LOG_LOCAL3, |
| 615 | [4] = LOG_LOCAL4, |
| 616 | [5] = LOG_LOCAL5, |
| 617 | [6] = LOG_LOCAL6, |
| 618 | [7] = LOG_LOCAL7 |
| 619 | }; |
| 620 | |
Harald Welte | de79cee | 2011-02-24 23:47:57 +0100 | [diff] [blame] | 621 | /* From VTY core code */ |
| 622 | extern struct host host; |
| 623 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 624 | static int _cfg_log_syslog(struct vty *vty, int facility) |
| 625 | { |
| 626 | struct log_target *tgt; |
| 627 | |
| 628 | /* First delete the old syslog target, if any */ |
| 629 | tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL); |
| 630 | if (tgt) |
| 631 | log_target_destroy(tgt); |
| 632 | |
Harald Welte | de79cee | 2011-02-24 23:47:57 +0100 | [diff] [blame] | 633 | tgt = log_target_create_syslog(host.app_info->name, 0, facility); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 634 | if (!tgt) { |
| 635 | vty_out(vty, "%% Unable to open syslog%s", VTY_NEWLINE); |
| 636 | return CMD_WARNING; |
| 637 | } |
| 638 | log_add_target(tgt); |
| 639 | |
| 640 | vty->index = tgt; |
| 641 | vty->node = CFG_LOG_NODE; |
| 642 | |
| 643 | return CMD_SUCCESS; |
| 644 | } |
| 645 | |
| 646 | DEFUN(cfg_log_syslog_local, cfg_log_syslog_local_cmd, |
| 647 | "log syslog local <0-7>", |
| 648 | LOG_STR "Logging via syslog\n" "Syslog LOCAL facility\n" |
| 649 | "Local facility number\n") |
| 650 | { |
| 651 | int local = atoi(argv[0]); |
| 652 | int facility = local_sysl_map[local]; |
| 653 | |
| 654 | return _cfg_log_syslog(vty, facility); |
| 655 | } |
| 656 | |
| 657 | static struct value_string sysl_level_names[] = { |
| 658 | { LOG_AUTHPRIV, "authpriv" }, |
| 659 | { LOG_CRON, "cron" }, |
| 660 | { LOG_DAEMON, "daemon" }, |
| 661 | { LOG_FTP, "ftp" }, |
| 662 | { LOG_LPR, "lpr" }, |
| 663 | { LOG_MAIL, "mail" }, |
| 664 | { LOG_NEWS, "news" }, |
| 665 | { LOG_USER, "user" }, |
| 666 | { LOG_UUCP, "uucp" }, |
| 667 | /* only for value -> string conversion */ |
| 668 | { LOG_LOCAL0, "local 0" }, |
| 669 | { LOG_LOCAL1, "local 1" }, |
| 670 | { LOG_LOCAL2, "local 2" }, |
| 671 | { LOG_LOCAL3, "local 3" }, |
| 672 | { LOG_LOCAL4, "local 4" }, |
| 673 | { LOG_LOCAL5, "local 5" }, |
| 674 | { LOG_LOCAL6, "local 6" }, |
| 675 | { LOG_LOCAL7, "local 7" }, |
| 676 | { 0, NULL } |
| 677 | }; |
| 678 | |
| 679 | DEFUN(cfg_log_syslog, cfg_log_syslog_cmd, |
| 680 | "log syslog (authpriv|cron|daemon|ftp|lpr|mail|news|user|uucp)", |
Holger Hans Peter Freyther | a4463fd | 2011-10-03 23:17:36 +0200 | [diff] [blame] | 681 | LOG_STR "Logging via syslog\n" |
| 682 | "Security/authorization messages facility\n" |
| 683 | "Clock daemon (cron/at) facility\n" |
| 684 | "General system daemon facility\n" |
| 685 | "Ftp daemon facility\n" |
| 686 | "Line printer facility\n" |
| 687 | "Mail facility\n" |
| 688 | "News facility\n" |
| 689 | "Generic facility\n" |
| 690 | "UUCP facility\n") |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 691 | { |
| 692 | int facility = get_string_value(sysl_level_names, argv[0]); |
| 693 | |
| 694 | return _cfg_log_syslog(vty, facility); |
| 695 | } |
| 696 | |
| 697 | DEFUN(cfg_no_log_syslog, cfg_no_log_syslog_cmd, |
| 698 | "no log syslog", |
| 699 | NO_STR LOG_STR "Logging via syslog\n") |
| 700 | { |
| 701 | struct log_target *tgt; |
| 702 | |
| 703 | tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL); |
| 704 | if (!tgt) { |
| 705 | vty_out(vty, "%% No syslog target found%s", |
| 706 | VTY_NEWLINE); |
| 707 | return CMD_WARNING; |
| 708 | } |
| 709 | |
| 710 | log_target_destroy(tgt); |
| 711 | |
| 712 | return CMD_SUCCESS; |
| 713 | } |
| 714 | #endif /* HAVE_SYSLOG_H */ |
| 715 | |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 716 | DEFUN(cfg_log_gsmtap, cfg_log_gsmtap_cmd, |
| 717 | "log gsmtap [HOSTNAME]", |
Neels Hofmeyr | fd9ec3b | 2016-12-11 01:48:26 +0100 | [diff] [blame] | 718 | LOG_STR "Logging via GSMTAP\n" |
| 719 | "Host name to send the GSMTAP logging to (UDP port 4729)\n") |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 720 | { |
Max | 2f153b5 | 2018-01-04 12:25:57 +0100 | [diff] [blame] | 721 | const char *hostname = argc ? argv[0] : "127.0.0.1"; |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 722 | struct log_target *tgt; |
| 723 | |
| 724 | tgt = log_target_find(LOG_TGT_TYPE_GSMTAP, hostname); |
| 725 | if (!tgt) { |
| 726 | tgt = log_target_create_gsmtap(hostname, GSMTAP_UDP_PORT, |
| 727 | host.app_info->name, false, |
| 728 | true); |
| 729 | if (!tgt) { |
Max | 2f153b5 | 2018-01-04 12:25:57 +0100 | [diff] [blame] | 730 | vty_out(vty, "%% Unable to create GSMTAP log for %s%s", |
| 731 | hostname, VTY_NEWLINE); |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 732 | return CMD_WARNING; |
| 733 | } |
| 734 | log_add_target(tgt); |
| 735 | } |
| 736 | |
| 737 | vty->index = tgt; |
| 738 | vty->node = CFG_LOG_NODE; |
| 739 | |
| 740 | return CMD_SUCCESS; |
| 741 | } |
| 742 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 743 | DEFUN(cfg_log_stderr, cfg_log_stderr_cmd, |
| 744 | "log stderr", |
| 745 | LOG_STR "Logging via STDERR of the process\n") |
| 746 | { |
| 747 | struct log_target *tgt; |
| 748 | |
| 749 | tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL); |
| 750 | if (!tgt) { |
| 751 | tgt = log_target_create_stderr(); |
| 752 | if (!tgt) { |
| 753 | vty_out(vty, "%% Unable to create stderr log%s", |
| 754 | VTY_NEWLINE); |
| 755 | return CMD_WARNING; |
| 756 | } |
| 757 | log_add_target(tgt); |
| 758 | } |
| 759 | |
| 760 | vty->index = tgt; |
| 761 | vty->node = CFG_LOG_NODE; |
| 762 | |
| 763 | return CMD_SUCCESS; |
| 764 | } |
| 765 | |
| 766 | DEFUN(cfg_no_log_stderr, cfg_no_log_stderr_cmd, |
| 767 | "no log stderr", |
| 768 | NO_STR LOG_STR "Logging via STDERR of the process\n") |
| 769 | { |
| 770 | struct log_target *tgt; |
| 771 | |
| 772 | tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL); |
| 773 | if (!tgt) { |
| 774 | vty_out(vty, "%% No stderr logging active%s", VTY_NEWLINE); |
| 775 | return CMD_WARNING; |
| 776 | } |
| 777 | |
| 778 | log_target_destroy(tgt); |
| 779 | |
| 780 | return CMD_SUCCESS; |
| 781 | } |
| 782 | |
| 783 | DEFUN(cfg_log_file, cfg_log_file_cmd, |
| 784 | "log file .FILENAME", |
| 785 | LOG_STR "Logging to text file\n" "Filename\n") |
| 786 | { |
| 787 | const char *fname = argv[0]; |
| 788 | struct log_target *tgt; |
| 789 | |
| 790 | tgt = log_target_find(LOG_TGT_TYPE_FILE, fname); |
| 791 | if (!tgt) { |
| 792 | tgt = log_target_create_file(fname); |
| 793 | if (!tgt) { |
| 794 | vty_out(vty, "%% Unable to create file `%s'%s", |
| 795 | fname, VTY_NEWLINE); |
| 796 | return CMD_WARNING; |
| 797 | } |
| 798 | log_add_target(tgt); |
| 799 | } |
| 800 | |
| 801 | vty->index = tgt; |
| 802 | vty->node = CFG_LOG_NODE; |
| 803 | |
| 804 | return CMD_SUCCESS; |
| 805 | } |
| 806 | |
| 807 | |
| 808 | DEFUN(cfg_no_log_file, cfg_no_log_file_cmd, |
| 809 | "no log file .FILENAME", |
| 810 | NO_STR LOG_STR "Logging to text file\n" "Filename\n") |
| 811 | { |
| 812 | const char *fname = argv[0]; |
| 813 | struct log_target *tgt; |
| 814 | |
| 815 | tgt = log_target_find(LOG_TGT_TYPE_FILE, fname); |
| 816 | if (!tgt) { |
| 817 | vty_out(vty, "%% No such log file `%s'%s", |
| 818 | fname, VTY_NEWLINE); |
| 819 | return CMD_WARNING; |
| 820 | } |
| 821 | |
| 822 | log_target_destroy(tgt); |
| 823 | |
| 824 | return CMD_SUCCESS; |
| 825 | } |
| 826 | |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 827 | DEFUN(cfg_log_alarms, cfg_log_alarms_cmd, |
| 828 | "log alarms <2-32700>", |
| 829 | LOG_STR "Logging alarms to osmo_strrb\n" |
| 830 | "Maximum number of messages to log\n") |
| 831 | { |
| 832 | struct log_target *tgt; |
| 833 | unsigned int rbsize = atoi(argv[0]); |
| 834 | |
| 835 | tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL); |
| 836 | if (tgt) |
| 837 | log_target_destroy(tgt); |
| 838 | |
| 839 | tgt = log_target_create_rb(rbsize); |
| 840 | if (!tgt) { |
| 841 | vty_out(vty, "%% Unable to create osmo_strrb (size %u)%s", |
| 842 | rbsize, VTY_NEWLINE); |
| 843 | return CMD_WARNING; |
| 844 | } |
| 845 | log_add_target(tgt); |
| 846 | |
| 847 | vty->index = tgt; |
| 848 | vty->node = CFG_LOG_NODE; |
| 849 | |
| 850 | return CMD_SUCCESS; |
| 851 | } |
| 852 | |
| 853 | DEFUN(cfg_no_log_alarms, cfg_no_log_alarms_cmd, |
| 854 | "no log alarms", |
| 855 | NO_STR LOG_STR "Logging alarms to osmo_strrb\n") |
| 856 | { |
| 857 | struct log_target *tgt; |
| 858 | |
| 859 | tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL); |
| 860 | if (!tgt) { |
| 861 | vty_out(vty, "%% No osmo_strrb target found%s", VTY_NEWLINE); |
| 862 | return CMD_WARNING; |
| 863 | } |
| 864 | |
| 865 | log_target_destroy(tgt); |
| 866 | |
| 867 | return CMD_SUCCESS; |
| 868 | } |
| 869 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 870 | static int config_write_log_single(struct vty *vty, struct log_target *tgt) |
| 871 | { |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 872 | char level_buf[128]; |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 873 | int i; |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 874 | |
| 875 | switch (tgt->type) { |
| 876 | case LOG_TGT_TYPE_VTY: |
| 877 | return 1; |
| 878 | break; |
| 879 | case LOG_TGT_TYPE_STDERR: |
| 880 | vty_out(vty, "log stderr%s", VTY_NEWLINE); |
| 881 | break; |
| 882 | case LOG_TGT_TYPE_SYSLOG: |
| 883 | #ifdef HAVE_SYSLOG_H |
| 884 | vty_out(vty, "log syslog %s%s", |
| 885 | get_value_string(sysl_level_names, |
| 886 | tgt->tgt_syslog.facility), |
| 887 | VTY_NEWLINE); |
| 888 | #endif |
| 889 | break; |
| 890 | case LOG_TGT_TYPE_FILE: |
| 891 | vty_out(vty, "log file %s%s", tgt->tgt_file.fname, VTY_NEWLINE); |
| 892 | break; |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 893 | case LOG_TGT_TYPE_STRRB: |
| 894 | vty_out(vty, "log alarms %zu%s", |
| 895 | log_target_rb_avail_size(tgt), VTY_NEWLINE); |
| 896 | break; |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 897 | case LOG_TGT_TYPE_GSMTAP: |
| 898 | vty_out(vty, "log gsmtap %s%s", |
| 899 | tgt->tgt_gsmtap.hostname, VTY_NEWLINE); |
| 900 | break; |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 901 | } |
| 902 | |
Harald Welte | 0d67f48 | 2018-09-25 20:16:14 +0200 | [diff] [blame] | 903 | vty_out(vty, " logging filter all %u%s", |
Neels Hofmeyr | 8b86cd7 | 2017-02-23 18:03:28 +0100 | [diff] [blame] | 904 | tgt->filter_map & (1 << LOG_FLT_ALL) ? 1 : 0, VTY_NEWLINE); |
Harald Welte | fb84f32 | 2013-06-06 07:33:54 +0200 | [diff] [blame] | 905 | /* save filters outside of libosmocore, i.e. in app code */ |
| 906 | if (osmo_log_info->save_fn) |
| 907 | osmo_log_info->save_fn(vty, osmo_log_info, tgt); |
Harald Welte | 2da47f1 | 2012-10-22 19:31:54 +0200 | [diff] [blame] | 908 | |
Harald Welte | 0d67f48 | 2018-09-25 20:16:14 +0200 | [diff] [blame] | 909 | vty_out(vty, " logging color %u%s", tgt->use_color ? 1 : 0, |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 910 | VTY_NEWLINE); |
Vadim Yanitskiy | 5c4b985 | 2019-07-28 04:36:37 +0700 | [diff] [blame] | 911 | vty_out(vty, " logging print category-hex %d%s", |
| 912 | tgt->print_category_hex ? 1 : 0, VTY_NEWLINE); |
Harald Welte | 0d67f48 | 2018-09-25 20:16:14 +0200 | [diff] [blame] | 913 | vty_out(vty, " logging print category %d%s", |
Michael McTernan | 7893346 | 2015-03-20 15:29:25 +0100 | [diff] [blame] | 914 | tgt->print_category ? 1 : 0, VTY_NEWLINE); |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 915 | if (tgt->print_ext_timestamp) |
Harald Welte | 0d67f48 | 2018-09-25 20:16:14 +0200 | [diff] [blame] | 916 | vty_out(vty, " logging print extended-timestamp 1%s", VTY_NEWLINE); |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 917 | else |
Harald Welte | 0d67f48 | 2018-09-25 20:16:14 +0200 | [diff] [blame] | 918 | vty_out(vty, " logging timestamp %u%s", |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 919 | tgt->print_timestamp ? 1 : 0, VTY_NEWLINE); |
Neels Hofmeyr | 886e548 | 2018-01-16 01:49:37 +0100 | [diff] [blame] | 920 | if (tgt->print_level) |
Harald Welte | 0d67f48 | 2018-09-25 20:16:14 +0200 | [diff] [blame] | 921 | vty_out(vty, " logging print level 1%s", VTY_NEWLINE); |
| 922 | vty_out(vty, " logging print file %s%s", |
Neels Hofmeyr | 22772cc | 2018-02-06 00:52:08 +0100 | [diff] [blame] | 923 | get_value_string(logging_print_file_args, tgt->print_filename2), |
| 924 | VTY_NEWLINE); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 925 | |
Neels Hofmeyr | 098038a | 2018-09-11 23:49:13 +0200 | [diff] [blame] | 926 | if (tgt->loglevel) { |
| 927 | const char *level_str = get_value_string_or_null(loglevel_strs, tgt->loglevel); |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 928 | if (!level_str) { |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 929 | vty_out(vty, "%% Invalid log level %u for 'force-all'%s", |
| 930 | tgt->loglevel, VTY_NEWLINE); |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 931 | } else { |
| 932 | osmo_str_tolower_buf(level_buf, sizeof(level_buf), level_str); |
| 933 | vty_out(vty, " logging level force-all %s%s", level_buf, VTY_NEWLINE); |
| 934 | } |
Neels Hofmeyr | 098038a | 2018-09-11 23:49:13 +0200 | [diff] [blame] | 935 | } |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 936 | |
| 937 | for (i = 0; i < osmo_log_info->num_cat; i++) { |
| 938 | const struct log_category *cat = &tgt->categories[i]; |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 939 | char cat_name[128]; |
Neels Hofmeyr | 098038a | 2018-09-11 23:49:13 +0200 | [diff] [blame] | 940 | const char *level_str; |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 941 | |
Harald Welte | 1a02cfc | 2013-03-19 10:37:39 +0100 | [diff] [blame] | 942 | /* skip empty entries in the array */ |
| 943 | if (!osmo_log_info->cat[i].name) |
| 944 | continue; |
| 945 | |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 946 | osmo_str_tolower_buf(cat_name, sizeof(cat_name), osmo_log_info->cat[i].name + 1); |
Neels Hofmeyr | 098038a | 2018-09-11 23:49:13 +0200 | [diff] [blame] | 947 | |
| 948 | level_str = get_value_string_or_null(loglevel_strs, cat->loglevel); |
| 949 | if (!level_str) { |
| 950 | vty_out(vty, "%% Invalid log level %u for %s%s", cat->loglevel, cat_name, |
| 951 | VTY_NEWLINE); |
| 952 | continue; |
| 953 | } |
| 954 | |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 955 | osmo_str_tolower_buf(level_buf, sizeof(level_buf), level_str); |
Harald Welte | 0d67f48 | 2018-09-25 20:16:14 +0200 | [diff] [blame] | 956 | vty_out(vty, " logging level %s", cat_name); |
Pau Espin Pedrol | c21ba15 | 2019-08-02 20:32:34 +0200 | [diff] [blame] | 957 | vty_out(vty, " %s%s", level_buf, VTY_NEWLINE); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 958 | } |
| 959 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 960 | return 1; |
| 961 | } |
| 962 | |
| 963 | static int config_write_log(struct vty *vty) |
| 964 | { |
| 965 | struct log_target *dbg = vty->index; |
| 966 | |
| 967 | llist_for_each_entry(dbg, &osmo_log_target_list, entry) |
| 968 | config_write_log_single(vty, dbg); |
| 969 | |
| 970 | return 1; |
| 971 | } |
| 972 | |
Harald Welte | 11eb4b5 | 2018-06-09 17:41:31 +0200 | [diff] [blame] | 973 | static int log_deprecated_func(struct cmd_element *cmd, struct vty *vty, int argc, const char *argv[]) |
| 974 | { |
| 975 | vty_out(vty, "%% Ignoring deprecated '%s'%s", cmd->string, VTY_NEWLINE); |
| 976 | return CMD_WARNING; |
| 977 | } |
| 978 | |
| 979 | void logging_vty_add_deprecated_subsys(void *ctx, const char *name) |
| 980 | { |
| 981 | struct cmd_element *cmd = talloc_zero(ctx, struct cmd_element); |
| 982 | OSMO_ASSERT(cmd); |
Neels Hofmeyr | 7e0686c | 2018-09-10 20:58:52 +0200 | [diff] [blame] | 983 | cmd->string = talloc_asprintf(cmd, "logging level %s (debug|info|notice|error|fatal)", |
Harald Welte | 11eb4b5 | 2018-06-09 17:41:31 +0200 | [diff] [blame] | 984 | name); |
| 985 | printf("%s\n", cmd->string); |
| 986 | cmd->func = log_deprecated_func; |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 987 | cmd->doc = LEVEL_STR |
Harald Welte | 11eb4b5 | 2018-06-09 17:41:31 +0200 | [diff] [blame] | 988 | "Deprecated Category\n"; |
| 989 | cmd->attr = CMD_ATTR_DEPRECATED; |
| 990 | |
| 991 | install_element(CFG_LOG_NODE, cmd); |
| 992 | } |
| 993 | |
Harald Welte | 8c64825 | 2017-10-16 15:17:03 +0200 | [diff] [blame] | 994 | /*! Register logging related commands to the VTY. Call this once from |
| 995 | * your application if you want to support those commands. */ |
Max | c65c5b4 | 2017-03-15 13:20:23 +0100 | [diff] [blame] | 996 | void logging_vty_add_cmds() |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 997 | { |
| 998 | install_element_ve(&enable_logging_cmd); |
| 999 | install_element_ve(&disable_logging_cmd); |
| 1000 | install_element_ve(&logging_fltr_all_cmd); |
| 1001 | install_element_ve(&logging_use_clr_cmd); |
| 1002 | install_element_ve(&logging_prnt_timestamp_cmd); |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 1003 | install_element_ve(&logging_prnt_ext_timestamp_cmd); |
| 1004 | install_element_ve(&logging_prnt_cat_cmd); |
Neels Hofmeyr | bd7bd39 | 2018-01-16 01:52:29 +0100 | [diff] [blame] | 1005 | install_element_ve(&logging_prnt_cat_hex_cmd); |
Neels Hofmeyr | 886e548 | 2018-01-16 01:49:37 +0100 | [diff] [blame] | 1006 | install_element_ve(&logging_prnt_level_cmd); |
Neels Hofmeyr | c6fd245 | 2018-01-16 01:57:38 +0100 | [diff] [blame] | 1007 | install_element_ve(&logging_prnt_file_cmd); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 1008 | install_element_ve(&logging_set_category_mask_cmd); |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 1009 | install_element_ve(&logging_set_category_mask_old_cmd); |
Pablo Neira Ayuso | 04139f1 | 2011-03-09 13:05:08 +0100 | [diff] [blame] | 1010 | |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 1011 | /* logging level (<categories>) (debug|...|fatal) */ |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 1012 | gen_logging_level_cmd_strs(&logging_level_cmd, |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 1013 | LOG_LEVEL_ARGS, |
Neels Hofmeyr | 7e0686c | 2018-09-10 20:58:52 +0200 | [diff] [blame] | 1014 | LOG_LEVEL_STRS); |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 1015 | /* logging level (<categories>) everything */ |
Neels Hofmeyr | 7e0686c | 2018-09-10 20:58:52 +0200 | [diff] [blame] | 1016 | gen_logging_level_cmd_strs(&deprecated_logging_level_everything_cmd, |
| 1017 | "everything", EVERYTHING_STR); |
Neels Hofmeyr | ba0762d | 2018-09-10 13:56:03 +0200 | [diff] [blame] | 1018 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 1019 | install_element_ve(&logging_level_cmd); |
Neels Hofmeyr | 28fc078 | 2018-09-12 02:32:02 +0200 | [diff] [blame] | 1020 | install_element_ve(&logging_level_set_all_cmd); |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 1021 | install_element_ve(&logging_level_force_all_cmd); |
| 1022 | install_element_ve(&no_logging_level_force_all_cmd); |
Neels Hofmeyr | 7e0686c | 2018-09-10 20:58:52 +0200 | [diff] [blame] | 1023 | install_element_ve(&deprecated_logging_level_everything_cmd); |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 1024 | install_element_ve(&deprecated_logging_level_all_cmd); |
| 1025 | install_element_ve(&deprecated_logging_level_all_everything_cmd); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 1026 | install_element_ve(&show_logging_vty_cmd); |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 1027 | install_element_ve(&show_alarms_cmd); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 1028 | |
| 1029 | install_node(&cfg_log_node, config_write_log); |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 1030 | install_element(CFG_LOG_NODE, &logging_fltr_all_cmd); |
| 1031 | install_element(CFG_LOG_NODE, &logging_use_clr_cmd); |
| 1032 | install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd); |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 1033 | install_element(CFG_LOG_NODE, &logging_prnt_ext_timestamp_cmd); |
| 1034 | install_element(CFG_LOG_NODE, &logging_prnt_cat_cmd); |
Neels Hofmeyr | bd7bd39 | 2018-01-16 01:52:29 +0100 | [diff] [blame] | 1035 | install_element(CFG_LOG_NODE, &logging_prnt_cat_hex_cmd); |
Neels Hofmeyr | 886e548 | 2018-01-16 01:49:37 +0100 | [diff] [blame] | 1036 | install_element(CFG_LOG_NODE, &logging_prnt_level_cmd); |
Neels Hofmeyr | c6fd245 | 2018-01-16 01:57:38 +0100 | [diff] [blame] | 1037 | install_element(CFG_LOG_NODE, &logging_prnt_file_cmd); |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 1038 | install_element(CFG_LOG_NODE, &logging_level_cmd); |
Neels Hofmeyr | 28fc078 | 2018-09-12 02:32:02 +0200 | [diff] [blame] | 1039 | install_element(CFG_LOG_NODE, &logging_level_set_all_cmd); |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 1040 | install_element(CFG_LOG_NODE, &logging_level_force_all_cmd); |
| 1041 | install_element(CFG_LOG_NODE, &no_logging_level_force_all_cmd); |
Neels Hofmeyr | 7e0686c | 2018-09-10 20:58:52 +0200 | [diff] [blame] | 1042 | install_element(CFG_LOG_NODE, &deprecated_logging_level_everything_cmd); |
Neels Hofmeyr | 9540c24 | 2018-09-12 00:20:50 +0200 | [diff] [blame] | 1043 | install_element(CFG_LOG_NODE, &deprecated_logging_level_all_cmd); |
| 1044 | install_element(CFG_LOG_NODE, &deprecated_logging_level_all_everything_cmd); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 1045 | |
| 1046 | install_element(CONFIG_NODE, &cfg_log_stderr_cmd); |
| 1047 | install_element(CONFIG_NODE, &cfg_no_log_stderr_cmd); |
| 1048 | install_element(CONFIG_NODE, &cfg_log_file_cmd); |
| 1049 | install_element(CONFIG_NODE, &cfg_no_log_file_cmd); |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 1050 | install_element(CONFIG_NODE, &cfg_log_alarms_cmd); |
| 1051 | install_element(CONFIG_NODE, &cfg_no_log_alarms_cmd); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 1052 | #ifdef HAVE_SYSLOG_H |
| 1053 | install_element(CONFIG_NODE, &cfg_log_syslog_cmd); |
| 1054 | install_element(CONFIG_NODE, &cfg_log_syslog_local_cmd); |
| 1055 | install_element(CONFIG_NODE, &cfg_no_log_syslog_cmd); |
| 1056 | #endif |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 1057 | install_element(CONFIG_NODE, &cfg_log_gsmtap_cmd); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 1058 | } |