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