libosmovty
0.12.0.47-7c74
Osmocom VTY library
|
Configuration of logging from VTY. More...
#include <stdlib.h>
#include <string.h>
#include "../../config.h"
#include <osmocom/core/talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/strrb.h>
#include <osmocom/core/loggingrb.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/buffer.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/logging.h>
#include <syslog.h>
Macros | |
#define | LOG_STR "Configure logging sub-system\n" |
#define | SHOW_LOG_STR "Show current logging configuration\n" |
Functions | |
static void | _vty_output (struct log_target *tgt, unsigned int level, const char *line) |
struct log_target * | log_target_create_vty (struct vty *vty) |
DEFUN (enable_logging, enable_logging_cmd, "logging enable", LOGGING_STR "Enables logging to this vty\) | |
struct log_target * | osmo_log_vty2tgt (struct vty *vty) |
DEFUN (logging_fltr_all, logging_fltr_all_cmd, "logging filter all (0|1)", LOGGING_STR FILTER_STR "Do you want to log all messages?\ "Only print messages matched by other filters\" "Bypass filter and print all messages\") | |
DEFUN (logging_use_clr, logging_use_clr_cmd, "logging color (0|1)", LOGGING_STR "Configure color-printing for log messages\ "Don 't use color for printing messages\" "Use color for printing messages\") | |
DEFUN (logging_prnt_timestamp, logging_prnt_timestamp_cmd, "logging timestamp (0|1)", LOGGING_STR "Configure log message timestamping\ "Don 't prefix each log message\" "Prefix each log message with current timestamp\") | |
DEFUN (logging_prnt_ext_timestamp, logging_prnt_ext_timestamp_cmd, "logging print extended-timestamp (0|1)", LOGGING_STR "Log output settings\ "Configure log message timestamping\" "Don 't prefix each log message\" "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\") | |
DEFUN (logging_prnt_cat, logging_prnt_cat_cmd, "logging print category (0|1)", LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with category/subsystem name\") | |
DEFUN (logging_prnt_cat_hex, logging_prnt_cat_hex_cmd, "logging print category-hex (0|1)", LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with category/subsystem nr in hex('< 000b >')\") | |
DEFUN (logging_prnt_level, logging_prnt_level_cmd, "logging print level (0|1)", LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with the log level name\") | |
DEFUN (logging_prnt_file, logging_prnt_file_cmd, "logging print file (0|1|basename) [last]", LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with the source file and line\" "Prefix each log message with the source file 's basename(strip leading paths) and line\" "Log source file info at the end of a log line. If omitted, log source file info just" " before the log text.\") | |
DEFUN (logging_level, logging_level_cmd, NULL, NULL) | |
DEFUN (logging_set_category_mask, logging_set_category_mask_cmd, "logging set-log-mask MASK", LOGGING_STR "Set the logmask of this logging target\ "List of logging categories to log, e.g. 'abc:mno:xyz'. Available log categories depend on the specific" " application, refer to the 'logging level' command. Optionally add individual log levels like" " 'abc, 1:mno, 3:xyz, 5', where the level numbers are" " " OSMO_STRINGIFY(LOGL_DEBUG) "=" OSMO_STRINGIFY_VAL(LOGL_DEBUG) " " OSMO_STRINGIFY(LOGL_INFO) "=" OSMO_STRINGIFY_VAL(LOGL_INFO) " " OSMO_STRINGIFY(LOGL_NOTICE) "=" OSMO_STRINGIFY_VAL(LOGL_NOTICE) " " OSMO_STRINGIFY(LOGL_ERROR) "=" OSMO_STRINGIFY_VAL(LOGL_ERROR) " " OSMO_STRINGIFY(LOGL_FATAL) "=" OSMO_STRINGIFY_VAL(LOGL_FATAL) "\") | |
ALIAS_DEPRECATED (logging_set_category_mask, logging_set_category_mask_old_cmd, "logging set log mask MASK", LOGGING_STR "Decide which categories to output.\ "Log commands\" "Mask commands\" " 'set log mask' is deprecated, please refer to the docs of 'set-log-mask' instead\") | |
DEFUN (diable_logging, disable_logging_cmd, "logging disable", LOGGING_STR "Disables logging to this vty\) | |
static void | vty_print_logtarget (struct vty *vty, const struct log_info *info, const struct log_target *tgt) |
DEFUN (show_logging_vty, show_logging_vty_cmd, "show logging vty", SHOW_STR SHOW_LOG_STR "Show current logging configuration for this vty\) | |
DEFUN (show_alarms, show_alarms_cmd, "show alarms", SHOW_STR SHOW_LOG_STR "Show the contents of the logging ringbuffer\) | |
gDEFUN (cfg_description, cfg_description_cmd, "description .TEXT", "Save human-readable description of the object\ "Text until the end of the line\") | |
gDEFUN (cfg_no_description, cfg_no_description_cmd, "no description", NO_STR "Remove description of the object\) | |
static int | _cfg_log_syslog (struct vty *vty, int facility) |
DEFUN (cfg_log_syslog_local, cfg_log_syslog_local_cmd, "log syslog local <0-7>", LOG_STR "Logging via syslog\ "Syslog LOCAL facility\" "Local facility number\") | |
DEFUN (cfg_log_syslog, cfg_log_syslog_cmd, "log syslog (authpriv|cron|daemon|ftp|lpr|mail|news|user|uucp)", LOG_STR "Logging via syslog\ "Security/authorization messages facility\" "Clock daemon(cron/at) facility\" "General system daemon facility\" "Ftp daemon facility\" "Line printer facility\" "Mail facility\" "News facility\" "Generic facility\" "UUCP facility\") | |
DEFUN (cfg_no_log_syslog, cfg_no_log_syslog_cmd, "no log syslog", NO_STR LOG_STR "Logging via syslog\) | |
DEFUN (cfg_log_gsmtap, cfg_log_gsmtap_cmd, "log gsmtap [HOSTNAME]", LOG_STR "Logging via GSMTAP\ "Host name to send the GSMTAP logging to(UDP port 4729)\") | |
DEFUN (cfg_log_stderr, cfg_log_stderr_cmd, "log stderr", LOG_STR "Logging via STDERR of the process\) | |
DEFUN (cfg_no_log_stderr, cfg_no_log_stderr_cmd, "no log stderr", NO_STR LOG_STR "Logging via STDERR of the process\) | |
DEFUN (cfg_log_file, cfg_log_file_cmd, "log file .FILENAME", LOG_STR "Logging to text file\ "Filename\") | |
DEFUN (cfg_no_log_file, cfg_no_log_file_cmd, "no log file .FILENAME", NO_STR LOG_STR "Logging to text file\ "Filename\") | |
DEFUN (cfg_log_alarms, cfg_log_alarms_cmd, "log alarms <2-32700>", LOG_STR "Logging alarms to osmo_strrb\ "Maximum number of messages to log\") | |
DEFUN (cfg_no_log_alarms, cfg_no_log_alarms_cmd, "no log alarms", NO_STR LOG_STR "Logging alarms to osmo_strrb\) | |
static int | config_write_log_single (struct vty *vty, struct log_target *tgt) |
static int | config_write_log (struct vty *vty) |
static int | log_deprecated_func (struct cmd_element *cmd, struct vty *vty, int argc, const char *argv[]) |
void | logging_vty_add_deprecated_subsys (void *ctx, const char *name) |
void | logging_vty_add_cmds () |
Register logging related commands to the VTY. More... | |
Variables | |
const struct log_info * | osmo_log_info |
static const struct value_string | logging_print_file_args [] |
struct cmd_node | cfg_log_node |
static const int | local_sysl_map [] |
struct host | host |
static struct value_string | sysl_level_names [] |
Configuration of logging from VTY.
This module implements
You have to call logging_vty_add_cmds from your application once to enable both of the above.
#define LOG_STR "Configure logging sub-system\n" |
#define SHOW_LOG_STR "Show current logging configuration\n" |
|
static |
References host::app_info, CFG_LOG_NODE, CMD_SUCCESS, CMD_WARNING, vty::index, log_add_target(), log_target_create_syslog(), log_target_destroy(), log_target_find(), LOG_TGT_TYPE_SYSLOG, vty_app_info::name, vty::node, VTY_NEWLINE, and vty_out().
Referenced by DEFUN().
|
static |
References log_target::tgt_vty, and vty_out().
Referenced by log_target_create_vty().
ALIAS_DEPRECATED | ( | logging_set_category_mask | , |
logging_set_category_mask_old_cmd | , | ||
"logging set log mask MASK" | , | ||
LOGGING_STR "Decide which categories to output.\Log commands\ "Mask commands\" " 'set log mask' is | deprecated, | ||
please refer to the docs of 'set-log-mask' instead\" | |||
) |
Referenced by DEFUN().
|
static |
References config_write_log_single(), log_target::entry, vty::index, llist_for_each_entry, and osmo_log_target_list.
Referenced by logging_vty_add_cmds().
|
static |
References log_info::cat, log_target::categories, log_target::filter_map, get_value_string(), LOG_FLT_ALL, log_level_str(), log_target_rb_avail_size(), LOG_TGT_TYPE_FILE, LOG_TGT_TYPE_GSMTAP, LOG_TGT_TYPE_STDERR, LOG_TGT_TYPE_STRRB, LOG_TGT_TYPE_SYSLOG, LOG_TGT_TYPE_VTY, log_target::loglevel, log_category::loglevel, log_info_cat::name, log_info::num_cat, osmo_str_tolower(), log_target::print_category, log_target::print_ext_timestamp, log_target::print_filename2, log_target::print_level, log_target::print_timestamp, log_info::save_fn, log_target::tgt_file, log_target::tgt_gsmtap, log_target::tgt_syslog, log_target::type, log_target::use_color, VTY_NEWLINE, and vty_out().
Referenced by config_write_log().
DEFUN | ( | enable_logging | , |
enable_logging_cmd | , | ||
"logging enable" | , | ||
LOGGING_STR "Enables logging to this vty\ | |||
) |
References CMD_SUCCESS, CMD_WARNING, telnet_connection::dbg, if(), log_add_target(), log_target_create_vty(), vty::priv, VTY_NEWLINE, and vty_out().
DEFUN | ( | logging_fltr_all | , |
logging_fltr_all_cmd | , | ||
"logging filter all (0|1)" | , | ||
LOGGING_STR FILTER_STR "Do you want to log all messages?\ "Only print messages matched by other filters\" "Bypass filter and print all messages\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_set_all_filter(), and osmo_log_vty2tgt().
DEFUN | ( | logging_use_clr | , |
logging_use_clr_cmd | , | ||
"logging color (0|1)" | , | ||
LOGGING_STR "Configure color-printing for log messages\ "Don 't use color for printing messages\" "Use color for printing messages\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_set_use_color(), and osmo_log_vty2tgt().
DEFUN | ( | logging_prnt_timestamp | , |
logging_prnt_timestamp_cmd | , | ||
"logging timestamp (0|1)" | , | ||
LOGGING_STR "Configure log message timestamping\ "Don 't prefix each log message\" "Prefix each log message with current timestamp\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_set_print_timestamp(), and osmo_log_vty2tgt().
DEFUN | ( | logging_prnt_ext_timestamp | , |
logging_prnt_ext_timestamp_cmd | , | ||
"logging print extended-timestamp (0|1)" | , | ||
LOGGING_STR "Log output settings\ "Configure log message timestamping\" "Don 't prefix each log message\" "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_set_print_extended_timestamp(), and osmo_log_vty2tgt().
DEFUN | ( | logging_prnt_cat | , |
logging_prnt_cat_cmd | , | ||
"logging print category (0|1)" | , | ||
LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with category/subsystem name\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_set_print_category(), and osmo_log_vty2tgt().
DEFUN | ( | logging_prnt_cat_hex | , |
logging_prnt_cat_hex_cmd | , | ||
"logging print category-hex (0|1)" | , | ||
LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with category/subsystem nr in hex('< 000b >')\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_set_print_category_hex(), and osmo_log_vty2tgt().
DEFUN | ( | logging_prnt_level | , |
logging_prnt_level_cmd | , | ||
"logging print level (0|1)" | , | ||
LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with the log level name\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_set_print_level(), and osmo_log_vty2tgt().
DEFUN | ( | logging_prnt_file | , |
logging_prnt_file_cmd | , | ||
"logging print file (0|1|basename) " | [last], | ||
LOGGING_STR "Log output settings\ "Configure log message\" "Don 't prefix each log message\" "Prefix each log message with the source file and line\" "Prefix each log message with the source file 's basename(strip leading paths) and line\" "Log source file info at the end of a log line. If | omitted, | ||
log source file info just" " before the log text.\n" | |||
) |
DEFUN | ( | logging_level | , |
logging_level_cmd | , | ||
NULL | , | ||
NULL | |||
) |
DEFUN | ( | logging_set_category_mask | , |
logging_set_category_mask_cmd | , | ||
"logging set-log-mask MASK" | , | ||
LOGGING_STR "Set the logmask of this logging target\ "List of logging categories to | log, | ||
e.g. 'abc:mno:xyz'. Available log categories depend on the specific" " | application, | ||
refer to the 'logging level' command. Optionally add individual log levels like" " ' | abc, | ||
1:mno | , | ||
3:xyz | , | ||
5' | |||
) |
DEFUN | ( | diable_logging | , |
disable_logging_cmd | , | ||
"logging disable" | , | ||
LOGGING_STR "Disables logging to this vty\ | |||
) |
References CMD_SUCCESS, CMD_WARNING, telnet_connection::dbg, if(), log_del_target(), osmo_log_vty2tgt(), and vty::priv.
DEFUN | ( | show_logging_vty | , |
show_logging_vty_cmd | , | ||
"show logging vty" | , | ||
SHOW_STR SHOW_LOG_STR "Show current logging configuration for this vty\ | |||
) |
References CMD_SUCCESS, CMD_WARNING, osmo_log_vty2tgt(), and vty_print_logtarget().
DEFUN | ( | show_alarms | , |
show_alarms_cmd | , | ||
"show alarms" | , | ||
SHOW_STR SHOW_LOG_STR "Show the contents of the logging ringbuffer\ | |||
) |
DEFUN | ( | cfg_log_syslog_local | , |
cfg_log_syslog_local_cmd | , | ||
"log syslog local <0-7>" | , | ||
LOG_STR "Logging via syslog\ "Syslog LOCAL facility\" "Local facility number\" | |||
) |
References _cfg_log_syslog(), and log_target::facility.
DEFUN | ( | cfg_log_syslog | , |
cfg_log_syslog_cmd | , | ||
"log syslog (authpriv|cron|daemon|ftp|lpr|mail|news|user|uucp)" | , | ||
LOG_STR "Logging via syslog\ "Security/authorization messages facility\" "Clock daemon(cron/at) facility\" "General system daemon facility\" "Ftp daemon facility\" "Line printer facility\" "Mail facility\" "News facility\" "Generic facility\" "UUCP facility\" | |||
) |
References _cfg_log_syslog(), and get_string_value().
DEFUN | ( | cfg_no_log_syslog | , |
cfg_no_log_syslog_cmd | , | ||
"no log syslog" | , | ||
NO_STR LOG_STR "Logging via syslog\ | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_target_destroy(), log_target_find(), LOG_TGT_TYPE_SYSLOG, VTY_NEWLINE, and vty_out().
DEFUN | ( | cfg_log_stderr | , |
cfg_log_stderr_cmd | , | ||
"log stderr" | , | ||
LOG_STR "Logging via STDERR of the process\ | |||
) |
DEFUN | ( | cfg_no_log_stderr | , |
cfg_no_log_stderr_cmd | , | ||
"no log stderr" | , | ||
NO_STR LOG_STR "Logging via STDERR of the process\ | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_target_destroy(), log_target_find(), LOG_TGT_TYPE_STDERR, VTY_NEWLINE, and vty_out().
DEFUN | ( | cfg_no_log_file | , |
cfg_no_log_file_cmd | , | ||
"no log file .FILENAME" | , | ||
NO_STR LOG_STR "Logging to text file\ "Filename\" | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_target::fname, log_target_destroy(), log_target_find(), LOG_TGT_TYPE_FILE, VTY_NEWLINE, and vty_out().
DEFUN | ( | cfg_log_alarms | , |
cfg_log_alarms_cmd | , | ||
"log alarms <2-32700>" | , | ||
LOG_STR "Logging alarms to osmo_strrb\ "Maximum number of messages to log\" | |||
) |
DEFUN | ( | cfg_no_log_alarms | , |
cfg_no_log_alarms_cmd | , | ||
"no log alarms" | , | ||
NO_STR LOG_STR "Logging alarms to osmo_strrb\ | |||
) |
References CMD_SUCCESS, CMD_WARNING, log_target_destroy(), log_target_find(), LOG_TGT_TYPE_STRRB, VTY_NEWLINE, and vty_out().
gDEFUN | ( | cfg_description | , |
cfg_description_cmd | , | ||
"description .TEXT" | , | ||
"Save human-readable description of the object\ "Text until the end of the line\" | |||
) |
References argv_concat(), CMD_SUCCESS, CMD_WARNING, vty::index_sub, VTY_NEWLINE, and vty_out().
gDEFUN | ( | cfg_no_description | , |
cfg_no_description_cmd | , | ||
"no description" | , | ||
NO_STR "Remove description of the object\ | |||
) |
References CMD_SUCCESS, CMD_WARNING, vty::index_sub, VTY_NEWLINE, and vty_out().
|
static |
References CMD_WARNING, cmd_element::string, VTY_NEWLINE, and vty_out().
Referenced by logging_vty_add_deprecated_subsys().
struct log_target* log_target_create_vty | ( | struct vty * | vty | ) |
References _vty_output(), log_target_create(), log_target::output, log_target::tgt_vty, and log_target::vty.
Referenced by DEFUN().
void logging_vty_add_cmds | ( | ) |
Register logging related commands to the VTY.
Call this once from your application if you want to support those commands.
References CFG_LOG_NODE, CONFIG_NODE, config_write_log(), install_element(), install_element_ve(), install_node(), log_vty_command_description(), and log_vty_command_string().
void logging_vty_add_deprecated_subsys | ( | void * | ctx, |
const char * | name | ||
) |
struct log_target* osmo_log_vty2tgt | ( | struct vty * | vty | ) |
References CFG_LOG_NODE, telnet_connection::dbg, if(), vty::index, vty::node, vty::priv, VTY_NEWLINE, and vty_out().
Referenced by DEFUN().
|
static |
References log_info::cat, log_target::categories, log_info_cat::description, log_category::enabled, log_target::filter_map, LOG_FLT_ALL, log_level_str(), log_category::loglevel, log_target::loglevel, log_info_cat::name, log_info::num_cat, log_info::print_fn, log_target::print_timestamp, log_target::use_color, VTY_NEWLINE, and vty_out().
Referenced by DEFUN().
struct cmd_node cfg_log_node |
|
static |
|
static |
|
static |