logging: Add 'show logging vty' command to display current log config

As the logging config is getting more and more complex, it is good
if it can be displayed interactively.

WARNING: This needs libosmocore 0.1.6 or later!
This commit is contained in:
Harald Welte 2010-05-11 11:12:37 +02:00
parent f171a6e4fc
commit 6f65696459
2 changed files with 45 additions and 1 deletions

View File

@ -18,7 +18,7 @@ dnl checks for libraries
AC_SEARCH_LIBS(crypt, crypt,
[LIBCRYPT="-lcrypt"; AC_DEFINE([VTY_CRYPT_PW], [], [Use crypt functionality of vty.])])
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.1.3)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.1.6)
dnl checks for header files
AC_HEADER_STDC

View File

@ -262,6 +262,49 @@ DEFUN(diable_logging,
return CMD_SUCCESS;
}
static void vty_print_logtarget(struct vty *vty, const struct log_info *info,
const struct log_target *tgt)
{
unsigned int i;
vty_out(vty, " Global Loglevel: %s%s",
log_level_str(tgt->loglevel), VTY_NEWLINE);
vty_out(vty, " Use color: %s, Print Timestamp: %s%s",
tgt->use_color ? "On" : "Off",
tgt->print_timestamp ? "On" : "Off", VTY_NEWLINE);
vty_out(vty, " Log Level specific information:%s", VTY_NEWLINE);
for (i = 0; i < info->num_cat; i++) {
const struct log_category *cat = &tgt->categories[i];
vty_out(vty, " %-10s %-10s %-8s %s%s",
info->cat[i].name+1, log_level_str(cat->loglevel),
cat->enabled ? "Enabled" : "Disabled",
info->cat[i].description,
VTY_NEWLINE);
}
}
#define SHOW_LOG_STR "Show current logging configuration\n"
DEFUN(show_logging_vty,
show_logging_vty_cmd,
"show logging vty",
SHOW_STR SHOW_LOG_STR
"Show current logging configuration for this vty\n")
{
struct telnet_connection *conn;
conn = (struct telnet_connection *) vty->priv;
if (!conn->dbg) {
vty_out(vty, "Logging was not enabled.%s", VTY_NEWLINE);
return CMD_WARNING;
}
vty_print_logtarget(vty, &log_info, conn->dbg);
return CMD_SUCCESS;
}
void openbsc_vty_print_statistics(struct vty *vty, struct gsm_network *net)
{
vty_out(vty, "Channel Requests : %lu total, %lu no channel%s",
@ -289,5 +332,6 @@ void openbsc_vty_add_cmds()
install_element(VIEW_NODE, &logging_prnt_timestamp_cmd);
install_element(VIEW_NODE, &logging_set_category_mask_cmd);
install_element(VIEW_NODE, &logging_level_cmd);
install_element(VIEW_NODE, &show_logging_vty_cmd);
}