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 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <stdlib.h> |
| 23 | #include <string.h> |
| 24 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 25 | #include "../../config.h" |
| 26 | |
Pablo Neira Ayuso | 8341934 | 2011-03-22 16:36:13 +0100 | [diff] [blame] | 27 | #include <osmocom/core/talloc.h> |
| 28 | #include <osmocom/core/logging.h> |
| 29 | #include <osmocom/core/utils.h> |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 30 | #include <osmocom/core/strrb.h> |
| 31 | #include <osmocom/core/loggingrb.h> |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 32 | #include <osmocom/core/gsmtap.h> |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 33 | |
| 34 | #include <osmocom/vty/command.h> |
| 35 | #include <osmocom/vty/buffer.h> |
| 36 | #include <osmocom/vty/vty.h> |
| 37 | #include <osmocom/vty/telnet_interface.h> |
| 38 | #include <osmocom/vty/logging.h> |
| 39 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 40 | #define LOG_STR "Configure logging sub-system\n" |
| 41 | |
Harald Welte | 8c64825 | 2017-10-16 15:17:03 +0200 | [diff] [blame] | 42 | /*! \file logging_vty.c |
Neels Hofmeyr | 87e4550 | 2017-06-20 00:17:59 +0200 | [diff] [blame] | 43 | * Configuration of logging from VTY |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 44 | * |
Harald Welte | 8c64825 | 2017-10-16 15:17:03 +0200 | [diff] [blame] | 45 | * This module implements |
| 46 | * - functions that permit configuration of the libosmocore logging |
| 47 | * framework from VTY commands in the configure -> logging node. |
| 48 | * |
| 49 | * - functions that permit logging *to* a VTY session. Basically each |
| 50 | * VTY session gets its own log target, with configurable |
| 51 | * per-subsystem log levels. This is performed internally via the |
| 52 | * \ref log_target_create_vty function. |
| 53 | * |
| 54 | * You have to call \ref logging_vty_add_cmds from your application |
| 55 | * once to enable both of the above. |
| 56 | * |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 57 | */ |
| 58 | |
Harald Welte | 4ebdf74 | 2010-05-19 19:54:00 +0200 | [diff] [blame] | 59 | extern const struct log_info *osmo_log_info; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 60 | |
Harald Welte | 76e72ab | 2011-02-17 15:52:39 +0100 | [diff] [blame] | 61 | static void _vty_output(struct log_target *tgt, |
| 62 | unsigned int level, const char *line) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 63 | { |
| 64 | struct vty *vty = tgt->tgt_vty.vty; |
| 65 | vty_out(vty, "%s", line); |
| 66 | /* This is an ugly hack, but there is no easy way... */ |
| 67 | if (strchr(line, '\n')) |
| 68 | vty_out(vty, "\r"); |
| 69 | } |
| 70 | |
| 71 | struct log_target *log_target_create_vty(struct vty *vty) |
| 72 | { |
| 73 | struct log_target *target; |
| 74 | |
| 75 | target = log_target_create(); |
| 76 | if (!target) |
| 77 | return NULL; |
| 78 | |
| 79 | target->tgt_vty.vty = vty; |
| 80 | target->output = _vty_output; |
| 81 | return target; |
| 82 | } |
| 83 | |
| 84 | DEFUN(enable_logging, |
| 85 | enable_logging_cmd, |
| 86 | "logging enable", |
| 87 | LOGGING_STR |
| 88 | "Enables logging to this vty\n") |
| 89 | { |
| 90 | struct telnet_connection *conn; |
| 91 | |
| 92 | conn = (struct telnet_connection *) vty->priv; |
| 93 | if (conn->dbg) { |
| 94 | vty_out(vty, "Logging already enabled.%s", VTY_NEWLINE); |
| 95 | return CMD_WARNING; |
| 96 | } |
| 97 | |
| 98 | conn->dbg = log_target_create_vty(vty); |
| 99 | if (!conn->dbg) |
| 100 | return CMD_WARNING; |
| 101 | |
| 102 | log_add_target(conn->dbg); |
| 103 | return CMD_SUCCESS; |
| 104 | } |
| 105 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 106 | struct log_target *osmo_log_vty2tgt(struct vty *vty) |
| 107 | { |
| 108 | struct telnet_connection *conn; |
| 109 | |
| 110 | if (vty->node == CFG_LOG_NODE) |
| 111 | return vty->index; |
| 112 | |
| 113 | |
| 114 | conn = (struct telnet_connection *) vty->priv; |
| 115 | if (!conn->dbg) |
| 116 | vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE); |
| 117 | |
| 118 | return conn->dbg; |
| 119 | } |
| 120 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 121 | DEFUN(logging_fltr_all, |
| 122 | logging_fltr_all_cmd, |
| 123 | "logging filter all (0|1)", |
| 124 | LOGGING_STR FILTER_STR |
| 125 | "Do you want to log all messages?\n" |
| 126 | "Only print messages matched by other filters\n" |
| 127 | "Bypass filter and print all messages\n") |
| 128 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 129 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 130 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 131 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 132 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 133 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 134 | log_set_all_filter(tgt, atoi(argv[0])); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 135 | return CMD_SUCCESS; |
| 136 | } |
| 137 | |
| 138 | DEFUN(logging_use_clr, |
| 139 | logging_use_clr_cmd, |
| 140 | "logging color (0|1)", |
| 141 | LOGGING_STR "Configure color-printing for log messages\n" |
| 142 | "Don't use color for printing messages\n" |
| 143 | "Use color for printing messages\n") |
| 144 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 145 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 146 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 147 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 148 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 149 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 150 | log_set_use_color(tgt, atoi(argv[0])); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 151 | return CMD_SUCCESS; |
| 152 | } |
| 153 | |
| 154 | DEFUN(logging_prnt_timestamp, |
| 155 | logging_prnt_timestamp_cmd, |
| 156 | "logging timestamp (0|1)", |
| 157 | LOGGING_STR "Configure log message timestamping\n" |
| 158 | "Don't prefix each log message\n" |
| 159 | "Prefix each log message with current timestamp\n") |
| 160 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 161 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 162 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 163 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 164 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 165 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 166 | log_set_print_timestamp(tgt, atoi(argv[0])); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 167 | return CMD_SUCCESS; |
| 168 | } |
| 169 | |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 170 | DEFUN(logging_prnt_ext_timestamp, |
| 171 | logging_prnt_ext_timestamp_cmd, |
| 172 | "logging print extended-timestamp (0|1)", |
| 173 | LOGGING_STR "Log output settings\n" |
| 174 | "Configure log message timestamping\n" |
| 175 | "Don't prefix each log message\n" |
| 176 | "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\n") |
| 177 | { |
| 178 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 179 | |
| 180 | if (!tgt) |
| 181 | return CMD_WARNING; |
| 182 | |
| 183 | log_set_print_extended_timestamp(tgt, atoi(argv[0])); |
| 184 | return CMD_SUCCESS; |
| 185 | } |
| 186 | |
| 187 | DEFUN(logging_prnt_cat, |
| 188 | logging_prnt_cat_cmd, |
| 189 | "logging print category (0|1)", |
| 190 | LOGGING_STR "Log output settings\n" |
| 191 | "Configure log message\n" |
| 192 | "Don't prefix each log message\n" |
| 193 | "Prefix each log message with category/subsystem name\n") |
| 194 | { |
| 195 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 196 | |
| 197 | if (!tgt) |
| 198 | return CMD_WARNING; |
| 199 | |
| 200 | log_set_print_category(tgt, atoi(argv[0])); |
| 201 | return CMD_SUCCESS; |
| 202 | } |
| 203 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 204 | DEFUN(logging_level, |
| 205 | logging_level_cmd, |
Pablo Neira Ayuso | 04139f1 | 2011-03-09 13:05:08 +0100 | [diff] [blame] | 206 | NULL, /* cmdstr is dynamically set in logging_vty_add_cmds(). */ |
| 207 | NULL) /* same thing for helpstr. */ |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 208 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 209 | int category = log_parse_category(argv[0]); |
| 210 | int level = log_parse_level(argv[1]); |
| 211 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 212 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 213 | if (!tgt) |
| 214 | return CMD_WARNING; |
| 215 | |
| 216 | if (level < 0) { |
| 217 | vty_out(vty, "Invalid level `%s'%s", argv[1], VTY_NEWLINE); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 218 | return CMD_WARNING; |
| 219 | } |
| 220 | |
Max | ed0eda2 | 2017-07-06 17:09:01 +0200 | [diff] [blame] | 221 | if (strcmp(argv[1], "everything") == 0) { /* FIXME: remove this check once 'everything' is phased out */ |
| 222 | vty_out(vty, "%% Ignoring deprecated logging level %s%s", argv[1], VTY_NEWLINE); |
| 223 | return CMD_SUCCESS; |
| 224 | } |
| 225 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 226 | /* Check for special case where we want to set global log level */ |
| 227 | if (!strcmp(argv[0], "all")) { |
| 228 | log_set_log_level(tgt, level); |
| 229 | return CMD_SUCCESS; |
| 230 | } |
| 231 | |
| 232 | if (category < 0) { |
| 233 | vty_out(vty, "Invalid category `%s'%s", argv[0], VTY_NEWLINE); |
| 234 | return CMD_WARNING; |
| 235 | } |
| 236 | |
| 237 | tgt->categories[category].enabled = 1; |
| 238 | tgt->categories[category].loglevel = level; |
| 239 | |
| 240 | return CMD_SUCCESS; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | DEFUN(logging_set_category_mask, |
| 244 | logging_set_category_mask_cmd, |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 245 | "logging set-log-mask MASK", |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 246 | LOGGING_STR |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 247 | "Set the logmask of this logging target\n" |
| 248 | "The logmask to use\n") |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 249 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 250 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 251 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 252 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 253 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 254 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 255 | log_parse_category_mask(tgt, argv[0]); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 256 | return CMD_SUCCESS; |
| 257 | } |
| 258 | |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 259 | ALIAS_DEPRECATED(logging_set_category_mask, |
| 260 | logging_set_category_mask_old_cmd, |
| 261 | "logging set log mask MASK", |
| 262 | LOGGING_STR |
| 263 | "Decide which categories to output.\n" |
| 264 | "Log commands\n" "Mask commands\n" "The logmask to use\n"); |
| 265 | |
| 266 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 267 | DEFUN(diable_logging, |
| 268 | disable_logging_cmd, |
| 269 | "logging disable", |
| 270 | LOGGING_STR |
| 271 | "Disables logging to this vty\n") |
| 272 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 273 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
| 274 | struct telnet_connection *conn = (struct telnet_connection *) vty->priv; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 275 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 276 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 277 | return CMD_WARNING; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 278 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 279 | log_del_target(tgt); |
| 280 | talloc_free(tgt); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 281 | conn->dbg = NULL; |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 282 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 283 | return CMD_SUCCESS; |
| 284 | } |
| 285 | |
| 286 | static void vty_print_logtarget(struct vty *vty, const struct log_info *info, |
| 287 | const struct log_target *tgt) |
| 288 | { |
| 289 | unsigned int i; |
| 290 | |
| 291 | vty_out(vty, " Global Loglevel: %s%s", |
| 292 | log_level_str(tgt->loglevel), VTY_NEWLINE); |
| 293 | vty_out(vty, " Use color: %s, Print Timestamp: %s%s", |
| 294 | tgt->use_color ? "On" : "Off", |
| 295 | tgt->print_timestamp ? "On" : "Off", VTY_NEWLINE); |
| 296 | |
| 297 | vty_out(vty, " Log Level specific information:%s", VTY_NEWLINE); |
| 298 | |
| 299 | for (i = 0; i < info->num_cat; i++) { |
| 300 | const struct log_category *cat = &tgt->categories[i]; |
Daniel Willmann | 55363a9 | 2016-11-15 10:05:51 +0100 | [diff] [blame] | 301 | /* Skip categories that were not initialized */ |
| 302 | if (!info->cat[i].name) |
| 303 | continue; |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 304 | vty_out(vty, " %-10s %-10s %-8s %s%s", |
| 305 | info->cat[i].name+1, log_level_str(cat->loglevel), |
| 306 | cat->enabled ? "Enabled" : "Disabled", |
| 307 | info->cat[i].description, |
| 308 | VTY_NEWLINE); |
| 309 | } |
Harald Welte | 6d2d4d6 | 2013-03-10 09:53:24 +0000 | [diff] [blame] | 310 | |
| 311 | vty_out(vty, " Log Filter 'ALL': %s%s", |
Neels Hofmeyr | 8b86cd7 | 2017-02-23 18:03:28 +0100 | [diff] [blame] | 312 | tgt->filter_map & (1 << LOG_FLT_ALL) ? "Enabled" : "Disabled", |
Harald Welte | 6d2d4d6 | 2013-03-10 09:53:24 +0000 | [diff] [blame] | 313 | VTY_NEWLINE); |
| 314 | |
Harald Welte | fb84f32 | 2013-06-06 07:33:54 +0200 | [diff] [blame] | 315 | /* print application specific filters */ |
| 316 | if (info->print_fn) |
| 317 | info->print_fn(vty, info, tgt); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | #define SHOW_LOG_STR "Show current logging configuration\n" |
| 321 | |
| 322 | DEFUN(show_logging_vty, |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 323 | show_logging_vty_cmd, |
| 324 | "show logging vty", |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 325 | SHOW_STR SHOW_LOG_STR |
| 326 | "Show current logging configuration for this vty\n") |
| 327 | { |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 328 | struct log_target *tgt = osmo_log_vty2tgt(vty); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 329 | |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 330 | if (!tgt) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 331 | return CMD_WARNING; |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 332 | |
| 333 | vty_print_logtarget(vty, osmo_log_info, tgt); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 334 | |
| 335 | return CMD_SUCCESS; |
| 336 | } |
| 337 | |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 338 | DEFUN(show_alarms, |
| 339 | show_alarms_cmd, |
| 340 | "show alarms", |
| 341 | SHOW_STR SHOW_LOG_STR |
| 342 | "Show the contents of the logging ringbuffer\n") |
| 343 | { |
| 344 | int i, num_alarms; |
| 345 | struct osmo_strrb *rb; |
| 346 | struct log_target *tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL); |
| 347 | if (!tgt) { |
| 348 | vty_out(vty, "%% No alarms, run 'log alarms <2-32700>'%s", |
| 349 | VTY_NEWLINE); |
| 350 | return CMD_WARNING; |
| 351 | } |
| 352 | |
| 353 | rb = tgt->tgt_rb.rb; |
| 354 | num_alarms = osmo_strrb_elements(rb); |
| 355 | |
| 356 | vty_out(vty, "%% Showing %i alarms%s", num_alarms, VTY_NEWLINE); |
| 357 | |
| 358 | for (i = 0; i < num_alarms; i++) |
| 359 | vty_out(vty, "%% %s%s", osmo_strrb_get_nth(rb, i), |
| 360 | VTY_NEWLINE); |
| 361 | |
| 362 | return CMD_SUCCESS; |
| 363 | } |
| 364 | |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 365 | gDEFUN(cfg_description, cfg_description_cmd, |
| 366 | "description .TEXT", |
Thorsten Alteholz | a81055d | 2017-03-02 22:13:48 +0100 | [diff] [blame] | 367 | "Save human-readable description of the object\n" |
Holger Hans Peter Freyther | c9b3e06 | 2012-07-25 13:02:49 +0200 | [diff] [blame] | 368 | "Text until the end of the line\n") |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 369 | { |
| 370 | char **dptr = vty->index_sub; |
| 371 | |
| 372 | if (!dptr) { |
| 373 | vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE); |
| 374 | return CMD_WARNING; |
| 375 | } |
| 376 | |
Holger Hans Peter Freyther | ff0670e | 2011-02-24 14:20:41 +0100 | [diff] [blame] | 377 | if (*dptr) |
| 378 | talloc_free(*dptr); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 379 | *dptr = argv_concat(argv, argc, 0); |
Holger Hans Peter Freyther | 6a75d16 | 2013-07-14 09:07:11 +0200 | [diff] [blame] | 380 | if (!*dptr) |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 381 | return CMD_WARNING; |
| 382 | |
| 383 | return CMD_SUCCESS; |
| 384 | } |
| 385 | |
| 386 | gDEFUN(cfg_no_description, cfg_no_description_cmd, |
| 387 | "no description", |
| 388 | NO_STR |
| 389 | "Remove description of the object\n") |
| 390 | { |
| 391 | char **dptr = vty->index_sub; |
| 392 | |
| 393 | if (!dptr) { |
| 394 | vty_out(vty, "vty->index_sub == NULL%s", VTY_NEWLINE); |
| 395 | return CMD_WARNING; |
| 396 | } |
| 397 | |
| 398 | if (*dptr) { |
| 399 | talloc_free(*dptr); |
| 400 | *dptr = NULL; |
| 401 | } |
| 402 | |
| 403 | return CMD_SUCCESS; |
| 404 | } |
| 405 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 406 | /* Support for configuration of log targets != the current vty */ |
| 407 | |
| 408 | struct cmd_node cfg_log_node = { |
| 409 | CFG_LOG_NODE, |
| 410 | "%s(config-log)# ", |
| 411 | 1 |
| 412 | }; |
| 413 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 414 | #ifdef HAVE_SYSLOG_H |
| 415 | |
| 416 | #include <syslog.h> |
| 417 | |
| 418 | static const int local_sysl_map[] = { |
| 419 | [0] = LOG_LOCAL0, |
| 420 | [1] = LOG_LOCAL1, |
| 421 | [2] = LOG_LOCAL2, |
| 422 | [3] = LOG_LOCAL3, |
| 423 | [4] = LOG_LOCAL4, |
| 424 | [5] = LOG_LOCAL5, |
| 425 | [6] = LOG_LOCAL6, |
| 426 | [7] = LOG_LOCAL7 |
| 427 | }; |
| 428 | |
Harald Welte | de79cee | 2011-02-24 23:47:57 +0100 | [diff] [blame] | 429 | /* From VTY core code */ |
| 430 | extern struct host host; |
| 431 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 432 | static int _cfg_log_syslog(struct vty *vty, int facility) |
| 433 | { |
| 434 | struct log_target *tgt; |
| 435 | |
| 436 | /* First delete the old syslog target, if any */ |
| 437 | tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL); |
| 438 | if (tgt) |
| 439 | log_target_destroy(tgt); |
| 440 | |
Harald Welte | de79cee | 2011-02-24 23:47:57 +0100 | [diff] [blame] | 441 | tgt = log_target_create_syslog(host.app_info->name, 0, facility); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 442 | if (!tgt) { |
| 443 | vty_out(vty, "%% Unable to open syslog%s", VTY_NEWLINE); |
| 444 | return CMD_WARNING; |
| 445 | } |
| 446 | log_add_target(tgt); |
| 447 | |
| 448 | vty->index = tgt; |
| 449 | vty->node = CFG_LOG_NODE; |
| 450 | |
| 451 | return CMD_SUCCESS; |
| 452 | } |
| 453 | |
| 454 | DEFUN(cfg_log_syslog_local, cfg_log_syslog_local_cmd, |
| 455 | "log syslog local <0-7>", |
| 456 | LOG_STR "Logging via syslog\n" "Syslog LOCAL facility\n" |
| 457 | "Local facility number\n") |
| 458 | { |
| 459 | int local = atoi(argv[0]); |
| 460 | int facility = local_sysl_map[local]; |
| 461 | |
| 462 | return _cfg_log_syslog(vty, facility); |
| 463 | } |
| 464 | |
| 465 | static struct value_string sysl_level_names[] = { |
| 466 | { LOG_AUTHPRIV, "authpriv" }, |
| 467 | { LOG_CRON, "cron" }, |
| 468 | { LOG_DAEMON, "daemon" }, |
| 469 | { LOG_FTP, "ftp" }, |
| 470 | { LOG_LPR, "lpr" }, |
| 471 | { LOG_MAIL, "mail" }, |
| 472 | { LOG_NEWS, "news" }, |
| 473 | { LOG_USER, "user" }, |
| 474 | { LOG_UUCP, "uucp" }, |
| 475 | /* only for value -> string conversion */ |
| 476 | { LOG_LOCAL0, "local 0" }, |
| 477 | { LOG_LOCAL1, "local 1" }, |
| 478 | { LOG_LOCAL2, "local 2" }, |
| 479 | { LOG_LOCAL3, "local 3" }, |
| 480 | { LOG_LOCAL4, "local 4" }, |
| 481 | { LOG_LOCAL5, "local 5" }, |
| 482 | { LOG_LOCAL6, "local 6" }, |
| 483 | { LOG_LOCAL7, "local 7" }, |
| 484 | { 0, NULL } |
| 485 | }; |
| 486 | |
| 487 | DEFUN(cfg_log_syslog, cfg_log_syslog_cmd, |
| 488 | "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] | 489 | LOG_STR "Logging via syslog\n" |
| 490 | "Security/authorization messages facility\n" |
| 491 | "Clock daemon (cron/at) facility\n" |
| 492 | "General system daemon facility\n" |
| 493 | "Ftp daemon facility\n" |
| 494 | "Line printer facility\n" |
| 495 | "Mail facility\n" |
| 496 | "News facility\n" |
| 497 | "Generic facility\n" |
| 498 | "UUCP facility\n") |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 499 | { |
| 500 | int facility = get_string_value(sysl_level_names, argv[0]); |
| 501 | |
| 502 | return _cfg_log_syslog(vty, facility); |
| 503 | } |
| 504 | |
| 505 | DEFUN(cfg_no_log_syslog, cfg_no_log_syslog_cmd, |
| 506 | "no log syslog", |
| 507 | NO_STR LOG_STR "Logging via syslog\n") |
| 508 | { |
| 509 | struct log_target *tgt; |
| 510 | |
| 511 | tgt = log_target_find(LOG_TGT_TYPE_SYSLOG, NULL); |
| 512 | if (!tgt) { |
| 513 | vty_out(vty, "%% No syslog target found%s", |
| 514 | VTY_NEWLINE); |
| 515 | return CMD_WARNING; |
| 516 | } |
| 517 | |
| 518 | log_target_destroy(tgt); |
| 519 | |
| 520 | return CMD_SUCCESS; |
| 521 | } |
| 522 | #endif /* HAVE_SYSLOG_H */ |
| 523 | |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 524 | DEFUN(cfg_log_gsmtap, cfg_log_gsmtap_cmd, |
| 525 | "log gsmtap [HOSTNAME]", |
Neels Hofmeyr | fd9ec3b | 2016-12-11 01:48:26 +0100 | [diff] [blame] | 526 | LOG_STR "Logging via GSMTAP\n" |
| 527 | "Host name to send the GSMTAP logging to (UDP port 4729)\n") |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 528 | { |
| 529 | const char *hostname = argv[0]; |
| 530 | struct log_target *tgt; |
| 531 | |
| 532 | tgt = log_target_find(LOG_TGT_TYPE_GSMTAP, hostname); |
| 533 | if (!tgt) { |
| 534 | tgt = log_target_create_gsmtap(hostname, GSMTAP_UDP_PORT, |
| 535 | host.app_info->name, false, |
| 536 | true); |
| 537 | if (!tgt) { |
| 538 | vty_out(vty, "%% Unable to create GSMTAP log%s", |
| 539 | VTY_NEWLINE); |
| 540 | return CMD_WARNING; |
| 541 | } |
| 542 | log_add_target(tgt); |
| 543 | } |
| 544 | |
| 545 | vty->index = tgt; |
| 546 | vty->node = CFG_LOG_NODE; |
| 547 | |
| 548 | return CMD_SUCCESS; |
| 549 | } |
| 550 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 551 | DEFUN(cfg_log_stderr, cfg_log_stderr_cmd, |
| 552 | "log stderr", |
| 553 | LOG_STR "Logging via STDERR of the process\n") |
| 554 | { |
| 555 | struct log_target *tgt; |
| 556 | |
| 557 | tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL); |
| 558 | if (!tgt) { |
| 559 | tgt = log_target_create_stderr(); |
| 560 | if (!tgt) { |
| 561 | vty_out(vty, "%% Unable to create stderr log%s", |
| 562 | VTY_NEWLINE); |
| 563 | return CMD_WARNING; |
| 564 | } |
| 565 | log_add_target(tgt); |
| 566 | } |
| 567 | |
| 568 | vty->index = tgt; |
| 569 | vty->node = CFG_LOG_NODE; |
| 570 | |
| 571 | return CMD_SUCCESS; |
| 572 | } |
| 573 | |
| 574 | DEFUN(cfg_no_log_stderr, cfg_no_log_stderr_cmd, |
| 575 | "no log stderr", |
| 576 | NO_STR LOG_STR "Logging via STDERR of the process\n") |
| 577 | { |
| 578 | struct log_target *tgt; |
| 579 | |
| 580 | tgt = log_target_find(LOG_TGT_TYPE_STDERR, NULL); |
| 581 | if (!tgt) { |
| 582 | vty_out(vty, "%% No stderr logging active%s", VTY_NEWLINE); |
| 583 | return CMD_WARNING; |
| 584 | } |
| 585 | |
| 586 | log_target_destroy(tgt); |
| 587 | |
| 588 | return CMD_SUCCESS; |
| 589 | } |
| 590 | |
| 591 | DEFUN(cfg_log_file, cfg_log_file_cmd, |
| 592 | "log file .FILENAME", |
| 593 | LOG_STR "Logging to text file\n" "Filename\n") |
| 594 | { |
| 595 | const char *fname = argv[0]; |
| 596 | struct log_target *tgt; |
| 597 | |
| 598 | tgt = log_target_find(LOG_TGT_TYPE_FILE, fname); |
| 599 | if (!tgt) { |
| 600 | tgt = log_target_create_file(fname); |
| 601 | if (!tgt) { |
| 602 | vty_out(vty, "%% Unable to create file `%s'%s", |
| 603 | fname, VTY_NEWLINE); |
| 604 | return CMD_WARNING; |
| 605 | } |
| 606 | log_add_target(tgt); |
| 607 | } |
| 608 | |
| 609 | vty->index = tgt; |
| 610 | vty->node = CFG_LOG_NODE; |
| 611 | |
| 612 | return CMD_SUCCESS; |
| 613 | } |
| 614 | |
| 615 | |
| 616 | DEFUN(cfg_no_log_file, cfg_no_log_file_cmd, |
| 617 | "no log file .FILENAME", |
| 618 | NO_STR LOG_STR "Logging to text file\n" "Filename\n") |
| 619 | { |
| 620 | const char *fname = argv[0]; |
| 621 | struct log_target *tgt; |
| 622 | |
| 623 | tgt = log_target_find(LOG_TGT_TYPE_FILE, fname); |
| 624 | if (!tgt) { |
| 625 | vty_out(vty, "%% No such log file `%s'%s", |
| 626 | fname, VTY_NEWLINE); |
| 627 | return CMD_WARNING; |
| 628 | } |
| 629 | |
| 630 | log_target_destroy(tgt); |
| 631 | |
| 632 | return CMD_SUCCESS; |
| 633 | } |
| 634 | |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 635 | DEFUN(cfg_log_alarms, cfg_log_alarms_cmd, |
| 636 | "log alarms <2-32700>", |
| 637 | LOG_STR "Logging alarms to osmo_strrb\n" |
| 638 | "Maximum number of messages to log\n") |
| 639 | { |
| 640 | struct log_target *tgt; |
| 641 | unsigned int rbsize = atoi(argv[0]); |
| 642 | |
| 643 | tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL); |
| 644 | if (tgt) |
| 645 | log_target_destroy(tgt); |
| 646 | |
| 647 | tgt = log_target_create_rb(rbsize); |
| 648 | if (!tgt) { |
| 649 | vty_out(vty, "%% Unable to create osmo_strrb (size %u)%s", |
| 650 | rbsize, VTY_NEWLINE); |
| 651 | return CMD_WARNING; |
| 652 | } |
| 653 | log_add_target(tgt); |
| 654 | |
| 655 | vty->index = tgt; |
| 656 | vty->node = CFG_LOG_NODE; |
| 657 | |
| 658 | return CMD_SUCCESS; |
| 659 | } |
| 660 | |
| 661 | DEFUN(cfg_no_log_alarms, cfg_no_log_alarms_cmd, |
| 662 | "no log alarms", |
| 663 | NO_STR LOG_STR "Logging alarms to osmo_strrb\n") |
| 664 | { |
| 665 | struct log_target *tgt; |
| 666 | |
| 667 | tgt = log_target_find(LOG_TGT_TYPE_STRRB, NULL); |
| 668 | if (!tgt) { |
| 669 | vty_out(vty, "%% No osmo_strrb target found%s", VTY_NEWLINE); |
| 670 | return CMD_WARNING; |
| 671 | } |
| 672 | |
| 673 | log_target_destroy(tgt); |
| 674 | |
| 675 | return CMD_SUCCESS; |
| 676 | } |
| 677 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 678 | static int config_write_log_single(struct vty *vty, struct log_target *tgt) |
| 679 | { |
| 680 | int i; |
| 681 | char level_lower[32]; |
| 682 | |
| 683 | switch (tgt->type) { |
| 684 | case LOG_TGT_TYPE_VTY: |
| 685 | return 1; |
| 686 | break; |
| 687 | case LOG_TGT_TYPE_STDERR: |
| 688 | vty_out(vty, "log stderr%s", VTY_NEWLINE); |
| 689 | break; |
| 690 | case LOG_TGT_TYPE_SYSLOG: |
| 691 | #ifdef HAVE_SYSLOG_H |
| 692 | vty_out(vty, "log syslog %s%s", |
| 693 | get_value_string(sysl_level_names, |
| 694 | tgt->tgt_syslog.facility), |
| 695 | VTY_NEWLINE); |
| 696 | #endif |
| 697 | break; |
| 698 | case LOG_TGT_TYPE_FILE: |
| 699 | vty_out(vty, "log file %s%s", tgt->tgt_file.fname, VTY_NEWLINE); |
| 700 | break; |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 701 | case LOG_TGT_TYPE_STRRB: |
| 702 | vty_out(vty, "log alarms %zu%s", |
| 703 | log_target_rb_avail_size(tgt), VTY_NEWLINE); |
| 704 | break; |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 705 | case LOG_TGT_TYPE_GSMTAP: |
| 706 | vty_out(vty, "log gsmtap %s%s", |
| 707 | tgt->tgt_gsmtap.hostname, VTY_NEWLINE); |
| 708 | break; |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 709 | } |
| 710 | |
Harald Welte | 2da47f1 | 2012-10-22 19:31:54 +0200 | [diff] [blame] | 711 | vty_out(vty, " logging filter all %u%s", |
Neels Hofmeyr | 8b86cd7 | 2017-02-23 18:03:28 +0100 | [diff] [blame] | 712 | tgt->filter_map & (1 << LOG_FLT_ALL) ? 1 : 0, VTY_NEWLINE); |
Harald Welte | fb84f32 | 2013-06-06 07:33:54 +0200 | [diff] [blame] | 713 | /* save filters outside of libosmocore, i.e. in app code */ |
| 714 | if (osmo_log_info->save_fn) |
| 715 | osmo_log_info->save_fn(vty, osmo_log_info, tgt); |
Harald Welte | 2da47f1 | 2012-10-22 19:31:54 +0200 | [diff] [blame] | 716 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 717 | vty_out(vty, " logging color %u%s", tgt->use_color ? 1 : 0, |
| 718 | VTY_NEWLINE); |
Holger Hans Peter Freyther | 879acef | 2015-01-27 11:06:51 +0100 | [diff] [blame] | 719 | vty_out(vty, " logging print category %d%s", |
Michael McTernan | 7893346 | 2015-03-20 15:29:25 +0100 | [diff] [blame] | 720 | tgt->print_category ? 1 : 0, VTY_NEWLINE); |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 721 | if (tgt->print_ext_timestamp) |
| 722 | vty_out(vty, " logging print extended-timestamp 1%s", VTY_NEWLINE); |
| 723 | else |
| 724 | vty_out(vty, " logging timestamp %u%s", |
| 725 | tgt->print_timestamp ? 1 : 0, VTY_NEWLINE); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 726 | |
| 727 | /* stupid old osmo logging API uses uppercase strings... */ |
| 728 | osmo_str2lower(level_lower, log_level_str(tgt->loglevel)); |
| 729 | vty_out(vty, " logging level all %s%s", level_lower, VTY_NEWLINE); |
| 730 | |
| 731 | for (i = 0; i < osmo_log_info->num_cat; i++) { |
| 732 | const struct log_category *cat = &tgt->categories[i]; |
| 733 | char cat_lower[32]; |
| 734 | |
Harald Welte | 1a02cfc | 2013-03-19 10:37:39 +0100 | [diff] [blame] | 735 | /* skip empty entries in the array */ |
| 736 | if (!osmo_log_info->cat[i].name) |
| 737 | continue; |
| 738 | |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 739 | /* stupid old osmo logging API uses uppercase strings... */ |
| 740 | osmo_str2lower(cat_lower, osmo_log_info->cat[i].name+1); |
| 741 | osmo_str2lower(level_lower, log_level_str(cat->loglevel)); |
| 742 | |
Max | ed0eda2 | 2017-07-06 17:09:01 +0200 | [diff] [blame] | 743 | if (strcmp(level_lower, "everything") != 0) /* FIXME: remove this check once 'everything' is phased out */ |
| 744 | vty_out(vty, " logging level %s %s%s", cat_lower, level_lower, VTY_NEWLINE); |
| 745 | else |
| 746 | LOGP(DLSTATS, LOGL_ERROR, "logging level everything is deprecated and should not be used\n"); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | /* FIXME: levels */ |
| 750 | |
| 751 | return 1; |
| 752 | } |
| 753 | |
| 754 | static int config_write_log(struct vty *vty) |
| 755 | { |
| 756 | struct log_target *dbg = vty->index; |
| 757 | |
| 758 | llist_for_each_entry(dbg, &osmo_log_target_list, entry) |
| 759 | config_write_log_single(vty, dbg); |
| 760 | |
| 761 | return 1; |
| 762 | } |
| 763 | |
Harald Welte | 8c64825 | 2017-10-16 15:17:03 +0200 | [diff] [blame] | 764 | /*! Register logging related commands to the VTY. Call this once from |
| 765 | * your application if you want to support those commands. */ |
Max | c65c5b4 | 2017-03-15 13:20:23 +0100 | [diff] [blame] | 766 | void logging_vty_add_cmds() |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 767 | { |
| 768 | install_element_ve(&enable_logging_cmd); |
| 769 | install_element_ve(&disable_logging_cmd); |
| 770 | install_element_ve(&logging_fltr_all_cmd); |
| 771 | install_element_ve(&logging_use_clr_cmd); |
| 772 | install_element_ve(&logging_prnt_timestamp_cmd); |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 773 | install_element_ve(&logging_prnt_ext_timestamp_cmd); |
| 774 | install_element_ve(&logging_prnt_cat_cmd); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 775 | install_element_ve(&logging_set_category_mask_cmd); |
Holger Hans Peter Freyther | 146d1d3 | 2011-10-03 23:15:41 +0200 | [diff] [blame] | 776 | install_element_ve(&logging_set_category_mask_old_cmd); |
Pablo Neira Ayuso | 04139f1 | 2011-03-09 13:05:08 +0100 | [diff] [blame] | 777 | |
| 778 | /* Logging level strings are generated dynamically. */ |
Max | c65c5b4 | 2017-03-15 13:20:23 +0100 | [diff] [blame] | 779 | logging_level_cmd.string = log_vty_command_string(); |
| 780 | logging_level_cmd.doc = log_vty_command_description(); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 781 | install_element_ve(&logging_level_cmd); |
| 782 | install_element_ve(&show_logging_vty_cmd); |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 783 | install_element_ve(&show_alarms_cmd); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 784 | |
| 785 | install_node(&cfg_log_node, config_write_log); |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 786 | install_element(CFG_LOG_NODE, &logging_fltr_all_cmd); |
| 787 | install_element(CFG_LOG_NODE, &logging_use_clr_cmd); |
| 788 | install_element(CFG_LOG_NODE, &logging_prnt_timestamp_cmd); |
Holger Hans Peter Freyther | 2d6ad13 | 2014-12-05 09:35:30 +0100 | [diff] [blame] | 789 | install_element(CFG_LOG_NODE, &logging_prnt_ext_timestamp_cmd); |
| 790 | install_element(CFG_LOG_NODE, &logging_prnt_cat_cmd); |
Harald Welte | a62648b | 2011-02-18 21:03:27 +0100 | [diff] [blame] | 791 | install_element(CFG_LOG_NODE, &logging_level_cmd); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 792 | |
| 793 | install_element(CONFIG_NODE, &cfg_log_stderr_cmd); |
| 794 | install_element(CONFIG_NODE, &cfg_no_log_stderr_cmd); |
| 795 | install_element(CONFIG_NODE, &cfg_log_file_cmd); |
| 796 | install_element(CONFIG_NODE, &cfg_no_log_file_cmd); |
Katerina Barone-Adesi | 3309a43 | 2013-02-21 05:16:29 +0000 | [diff] [blame] | 797 | install_element(CONFIG_NODE, &cfg_log_alarms_cmd); |
| 798 | install_element(CONFIG_NODE, &cfg_no_log_alarms_cmd); |
Harald Welte | 2822296 | 2011-02-18 20:37:04 +0100 | [diff] [blame] | 799 | #ifdef HAVE_SYSLOG_H |
| 800 | install_element(CONFIG_NODE, &cfg_log_syslog_cmd); |
| 801 | install_element(CONFIG_NODE, &cfg_log_syslog_local_cmd); |
| 802 | install_element(CONFIG_NODE, &cfg_no_log_syslog_cmd); |
| 803 | #endif |
Harald Welte | aa00f99 | 2016-12-02 15:30:02 +0100 | [diff] [blame] | 804 | install_element(CONFIG_NODE, &cfg_log_gsmtap_cmd); |
Harald Welte | 3fb0b6f | 2010-05-19 19:02:52 +0200 | [diff] [blame] | 805 | } |