libosmovty 1.13.1.1-afb4 Osmocom VTY library

Macros | Functions | Variables
logging_vty.c File Reference

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/logging_internal.h>`
`#include <osmocom/core/utils.h>`
`#include <osmocom/core/strrb.h>`
`#include <osmocom/core/loggingrb.h>`
`#include <osmocom/core/gsmtap.h>`
`#include <osmocom/core/gsmtap_util.h>`
`#include <osmocom/core/application.h>`
`#include <osmocom/core/socket.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>`

## Macros
#define | LOG_STR "Configure logging sub-system\n"
#define | LEVEL_STR "Set the log level for a specified category\n"
#define | CATEGORY_ALL_STR "Deprecated alias for 'force-all'\n"
#define | FORCE_ALL_STR
#define | NO_FORCE_ALL_STR "Release any globally forced log level set with 'logging level force-all <level>'\n"
#define | LOG_LEVEL_ARGS "(debug|info|notice|error|fatal)"
#define | LOG_LEVEL_STRS
#define | EVERYTHING_STR "Deprecated alias for 'no logging level force-all'\n"
#define | ACQUIRE_VTY_LOG_TGT_WITH_LOCK(vty, tgt)
| Get tgt with log lock acquired, return and release lock with warning if tgt is not found. More...
#define | RET_WITH_UNLOCK(ret)
#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\n")
struct log_target * | osmo_log_vty2tgt (struct vty *vty)
| Get log target associated to VTY console. More...
| DEFUN (logging_fltr_all, logging_fltr_all_cmd, "logging filter all (0|1)", LOGGING_STR FILTER_STR "Do you want to log all messages?\n" "Only print messages matched by other filters\n" "Bypass filter and print all messages\n")
| DEFUN (logging_use_clr, logging_use_clr_cmd, "logging color (0|1)", LOGGING_STR "Configure color-printing for log messages\n" "Don't use color for printing messages\n" "Use color for printing messages\n")
| DEFUN (logging_prnt_timestamp, logging_prnt_timestamp_cmd, "logging timestamp (0|1)", LOGGING_STR "Configure log message timestamping\n" "Don't prefix each log message\n" "Prefix each log message with current timestamp\n")
| DEFUN (logging_prnt_ext_timestamp, logging_prnt_ext_timestamp_cmd, "logging print extended-timestamp (0|1)", LOGGING_STR "Log output settings\n" "Configure log message timestamping\n" "Don't prefix each log message\n" "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\n")
| DEFUN (logging_prnt_tid, logging_prnt_tid_cmd, "logging print thread-id (0|1)", LOGGING_STR "Log output settings\n" "Configure log message logging Thread ID\n" "Don't prefix each log message\n" "Prefix each log message with current Thread ID\n")
| DEFUN (logging_prnt_cat, logging_prnt_cat_cmd, "logging print category (0|1)", LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with category/subsystem name\n")
| DEFUN (logging_prnt_cat_hex, logging_prnt_cat_hex_cmd, "logging print category-hex (0|1)", LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with category/subsystem nr in hex ('<000b>')\n")
| DEFUN (logging_prnt_level, logging_prnt_level_cmd, "logging print level (0|1)", LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with the log level name\n")
| DEFUN (logging_prnt_file, logging_prnt_file_cmd, "logging print file (0|1|basename) [last]", LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with the source file and line\n" "Prefix each log message with the source file's basename (strip leading paths) and line\n" "Log source file info at the end of a log line. If omitted, log source file info just" " before the log text.\n")
static void | add_category_strings (char **cmd_str_p, char **doc_str_p, const struct log_info *categories)
static void | gen_logging_level_cmd_strs (struct cmd_element *cmd, const char *level_args, const char *level_strs)
| DEFUN (logging_level, logging_level_cmd, NULL, NULL)
| DEFUN (logging_level_set_all, logging_level_set_all_cmd, "logging level set-all " LOG_LEVEL_ARGS, LOGGING_STR LEVEL_STR "Once-off set all categories to the given log level. There is no single command" " to take back these changes -- each category is set to the given level, period.\n" LOG_LEVEL_STRS)
| DEFUN_DEPRECATED (deprecated_logging_level_everything, deprecated_logging_level_everything_cmd, NULL, NULL)
| DEFUN (logging_level_force_all, logging_level_force_all_cmd, "logging level force-all " LOG_LEVEL_ARGS, LOGGING_STR LEVEL_STR FORCE_ALL_STR LOG_LEVEL_STRS)
| DEFUN (no_logging_level_force_all, no_logging_level_force_all_cmd, "no logging level force-all", NO_STR LOGGING_STR LEVEL_STR NO_FORCE_ALL_STR)
| ALIAS_DEPRECATED (logging_level_force_all, deprecated_logging_level_all_cmd, "logging level all " LOG_LEVEL_ARGS, LOGGING_STR LEVEL_STR CATEGORY_ALL_STR LOG_LEVEL_STRS)
| ALIAS_DEPRECATED (no_logging_level_force_all, deprecated_logging_level_all_everything_cmd, "logging level all everything", LOGGING_STR LEVEL_STR CATEGORY_ALL_STR EVERYTHING_STR)
| DEFUN (logging_set_category_mask, logging_set_category_mask_cmd, "logging set-log-mask MASK", LOGGING_STR "Set the logmask of this logging target\n" "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) "\n")
| ALIAS_DEPRECATED (logging_set_category_mask, logging_set_category_mask_old_cmd, "logging set log mask MASK", LOGGING_STR "Decide which categories to output.\n" "Log commands\n" "Mask commands\n" "'set log mask' is deprecated, please refer to the docs of 'set-log-mask' instead\n")
| DEFUN (diable_logging, disable_logging_cmd, "logging disable", LOGGING_STR "Disables logging to this vty\n")
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\n")
| DEFUN (show_alarms, show_alarms_cmd, "show alarms", SHOW_STR SHOW_LOG_STR "Show the contents of the logging ringbuffer\n")
| gDEFUN (cfg_description, cfg_description_cmd, "description .TEXT", "Save human-readable description of the object\n" "Text until the end of the line\n")
| gDEFUN (cfg_no_description, cfg_no_description_cmd, "no description", NO_STR "Remove description of the object\n")
| DEFUN (cfg_log_systemd_journal, cfg_log_systemd_journal_cmd, "log systemd-journal [raw]", LOG_STR "Logging to systemd-journal\n" "Offload rendering of the meta information (location, category) to systemd\n")
| DEFUN (cfg_no_log_systemd_journal, cfg_no_log_systemd_journal_cmd, "no log systemd-journal", NO_STR LOG_STR "Logging to systemd-journal\n")
| DEFUN (cfg_log_gsmtap, cfg_log_gsmtap_cmd, "log gsmtap [HOSTNAME] [(nonblocking-io|blocking-io|wq)]", LOG_STR "Logging via GSMTAP\n" "Host name to send the GSMTAP logging to (UDP port 4729)\n" "Use non-blocking, synchronous I/O (may lose msgs if UDP socket send buffer becomes full) (default)\n" "Use blocking, synchronous I/O (only for debug purposes or when blocking is acceptable)\n" "Use Tx workqueue, asynchronous I/O (may lose msgs if queue becomes full)\n")
| DEFUN (cfg_no_log_gsmtap, cfg_no_log_gsmtap_cmd, "no log gsmtap [HOSTNAME]", NO_STR LOG_STR "Logging via GSMTAP\n" "Host name to send the GSMTAP logging to (UDP port 4729)\n")
| DEFUN (cfg_log_stderr, cfg_log_stderr_cmd, "log stderr [(nonblocking-io|blocking-io|wq)]", LOG_STR "Logging via STDERR of the process\n" "Use non-blocking, synchronous I/O (may lose msgs if file write buffer becomes full) (default)\n" "Use blocking, synchronous I/O (only for debug purposes or when blocking is acceptable)\n" "Use Tx workqueue, asynchronous I/O (may lose msgs if queue becomes full)\n")
| DEFUN (cfg_no_log_stderr, cfg_no_log_stderr_cmd, "no log stderr", NO_STR LOG_STR "Logging via STDERR of the process\n")
| DEFUN (cfg_log_file, cfg_log_file_cmd, "log file FILENAME [(nonblocking-io|blocking-io|wq)]", LOG_STR "Logging to text file\n" "Filename\n" "Use non-blocking, synchronous I/O (may lose msgs if file write buffer becomes full) (default)\n" "Use blocking, synchronous I/O (only for debug purposes or when blocking is acceptable)\n" "Use Tx workqueue, asynchronous I/O (may lose msgs if queue becomes full)\n")
| DEFUN (cfg_no_log_file, cfg_no_log_file_cmd, "no log file FILENAME", NO_STR LOG_STR "Logging to text file\n" "Filename\n")
| DEFUN (cfg_log_alarms, cfg_log_alarms_cmd, "log alarms <2-32700>", LOG_STR "Logging alarms to osmo_strrb\n" "Maximum number of messages to log\n")
| DEFUN (cfg_no_log_alarms, cfg_no_log_alarms_cmd, "no log alarms", NO_STR LOG_STR "Logging alarms to osmo_strrb\n")
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)
| DEFUN (vty_logp, vty_logp_cmd, NULL, NULL)
static void | gen_vty_logp_cmd_strs (struct cmd_element *cmd)
void | logging_vty_add_cmds (void)
| Register logging related commands to the VTY. More...

## Variables
struct host | host
static const struct value_string | logging_print_file_args []
struct cmd_node | cfg_log_node

## Detailed Description

Configuration of logging from VTY.

This module implements

- functions that permit configuration of the libosmocore logging framework from VTY commands in the configure -> logging node.
- functions that permit logging to a VTY session. Basically each VTY session gets its own log target, with configurable per-subsystem log levels. This is performed internally via the log_target_create_vty function.

You have to call logging_vty_add_cmds from your application once to enable both of the above.

## Macro Definition Documentation

## ◆ ACQUIRE_VTY_LOG_TGT_WITH_LOCK

#define ACQUIRE_VTY_LOG_TGT_WITH_LOCK | ( |  | vty,
|  |  | tgt
| ) |  |

Value:
do { \
log_tgt_mutex_lock(); \
tgt = osmo_log_vty2tgt(vty); \
if (!(tgt)) { \
log_tgt_mutex_unlock(); \
return CMD_WARNING; \
} \
} while (0)
CMD_WARNING
#define CMD_WARNING
Definition: command.h:196
osmo_log_vty2tgt
struct log_target * osmo_log_vty2tgt(struct vty *vty)
Get log target associated to VTY console.
Definition: logging_vty.c:152
vty
Internal representation of a single VTY.
Definition: vty.h:60

Get tgt with log lock acquired, return and release lock with warning if tgt is not found.

Lock must be released later with log_tgt_mutex_unlock().

## ◆ CATEGORY_ALL_STR

#define CATEGORY_ALL_STR "Deprecated alias for 'force-all'\n"

## ◆ EVERYTHING_STR

#define EVERYTHING_STR "Deprecated alias for 'no logging level force-all'\n"

## ◆ FORCE_ALL_STR

#define FORCE_ALL_STR

Value:
"Globally force all logging categories to a specific level. This is released by the" \
" 'no logging level force-all' command. Note: any 'logging level <category> <level>'" \
" commands will have no visible effect after this, until the forced level is released.\n"

## ◆ LEVEL_STR

#define LEVEL_STR "Set the log level for a specified category\n"

## ◆ LOG_LEVEL_ARGS

#define LOG_LEVEL_ARGS "(debug|info|notice|error|fatal)"

## ◆ LOG_LEVEL_STRS

#define LOG_LEVEL_STRS

Value:
"Log debug messages and higher levels\n" \
"Log informational messages and higher levels\n" \
"Log noticeable messages and higher levels\n" \
"Log error messages and higher levels\n" \
"Log only fatal messages\n"

## ◆ LOG_STR

#define LOG_STR "Configure logging sub-system\n"

## ◆ NO_FORCE_ALL_STR

#define NO_FORCE_ALL_STR "Release any globally forced log level set with 'logging level force-all <level>'\n"

## ◆ RET_WITH_UNLOCK

#define RET_WITH_UNLOCK | ( |  | ret | ) |

Value:
do { \
log_tgt_mutex_unlock(); \
return (ret); \
} while (0)

## ◆ SHOW_LOG_STR

#define SHOW_LOG_STR "Show current logging configuration\n"

## Function Documentation

## ◆ _vty_output()

static void _vty_output | ( | struct log_target * | tgt,
|  | unsigned int | level,
|  | const char * | line
| ) |  |
| static

References log_target::tgt_vty, log_target::vty, and vty_out().

Referenced by log_target_create_vty().

## ◆ add_category_strings()

static void add_category_strings | ( | char ** | cmd_str_p,
|  | char ** | doc_str_p,
|  | const struct log_info * | categories
| ) |  |
| static

References log_target::categories, osmo_str_tolower_buf(), osmo_talloc_asprintf, and tall_log_ctx.

Referenced by gen_logging_level_cmd_strs(), and gen_vty_logp_cmd_strs().

## ◆ ALIAS_DEPRECATED() [1/3]

ALIAS_DEPRECATED | ( | logging_level_force_all | ,
|  | deprecated_logging_level_all_cmd | ,
|  | "logging level all " | LOG_LEVEL_ARGS,
|  | LOGGING_STR LEVEL_STR CATEGORY_ALL_STR | LOG_LEVEL_STRS
| ) |  |

## ◆ ALIAS_DEPRECATED() [2/3]

ALIAS_DEPRECATED | ( | logging_set_category_mask | ,
|  | logging_set_category_mask_old_cmd | ,
|  | "logging set log mask MASK" | ,
|  | LOGGING_STR "Decide which categories to output.\n" "Log commands\n" "Mask commands\n" "'set log mask' is | deprecated,
|  | please refer to the docs of 'set-log-mask' instead\n" |
| ) |  |

## ◆ ALIAS_DEPRECATED() [3/3]

ALIAS_DEPRECATED | ( | no_logging_level_force_all | ,
|  | deprecated_logging_level_all_everything_cmd | ,
|  | "logging level all everything" | ,
|  | LOGGING_STR LEVEL_STR CATEGORY_ALL_STR | EVERYTHING_STR
| ) |  |

## ◆ config_write_log()

static int config_write_log | ( | struct vty * | vty | ) |
| static

References config_write_log_single(), log_target::entry, vty::index, llist_for_each_entry, log_tgt_mutex_lock, log_tgt_mutex_unlock, and osmo_log_target_list.

Referenced by logging_vty_add_cmds().

## ◆ config_write_log_single()

static int config_write_log_single | ( | struct vty * | vty,
|  | struct log_target * | tgt
| ) |  |
| static

References log_info::cat, log_target::categories, log_target::facility, log_target::fname, get_value_string(), get_value_string_or_null(), log_target::gsmtap_inst, gsmtap_inst_fd2(), gsmtap_source_using_wq(), log_target::hostname, LOG_FILENAME_POS_LINE_END, LOG_FLT_ALL, log_target_file_get_nonblock(), log_target_rb_avail_size(), LOG_TGT_TYPE_EMSCRIPTEN, LOG_TGT_TYPE_FILE, LOG_TGT_TYPE_GSMTAP, LOG_TGT_TYPE_STDERR, LOG_TGT_TYPE_STRRB, LOG_TGT_TYPE_SYSLOG, LOG_TGT_TYPE_SYSTEMD, LOG_TGT_TYPE_VTY, logging_print_file_args, log_category::loglevel, log_target::loglevel, loglevel_strs, log_info_cat::name, log_info::num_cat, osmo_log_info, osmo_sock_get_nonblock(), osmo_str_tolower_buf(), log_target::print_category, log_target::print_category_hex, log_target::print_ext_timestamp, log_target::print_filename2, log_target::print_filename_pos, log_target::print_level, log_target::print_tid, log_target::print_timestamp, log_target::raw, log_info::save_fn, log_target::sd_journal, log_target::tgt_file, log_target::tgt_gsmtap, log_target::tgt_syslog, log_target::type, log_target::use_color, VTY_NEWLINE, vty_out(), and log_target::wqueue.

Referenced by config_write_log().

## ◆ DEFUN() [1/29]

DEFUN | ( | cfg_log_alarms | ,
|  | cfg_log_alarms_cmd | ,
|  | "log alarms <2-32700>" | ,
|  | LOG_STR "Logging alarms to osmo_strrb\n" "Maximum number of messages to log\n" |
| ) |  |

References argv, CFG_LOG_NODE, CMD_SUCCESS, CMD_WARNING, vty::index, log_add_target(), log_target_create_rb(), log_target_destroy(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_STRRB, vty::node, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [2/29]

DEFUN | ( | cfg_log_file | ,
|  | cfg_log_file_cmd | ,
|  | "log file FILENAME " | [(nonblocking-io|blocking-io|wq)],
|  | LOG_STR "Logging to text file\n" "Filename\n" "Use non- | blocking,
|  | synchronous I/O(may lose msgs if file write buffer becomes full)(default)\n" "Use | blocking,
|  | synchronous I/O(only for debug purposes or when blocking is acceptable)\n" "Use Tx | workqueue,
|  | asynchronous I/O(may lose msgs if queue becomes full)\n" |
| ) |  |

References argc, argv, CFG_LOG_NODE, CMD_SUCCESS, CMD_WARNING, log_target::fname, vty::index, log_add_target(), log_target_create_file(), log_target_file_set_nonblock(), log_target_file_switch_to_stream(), log_target_file_switch_to_wqueue(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_FILE, vty::node, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [3/29]

DEFUN | ( | cfg_log_gsmtap | ,
|  | cfg_log_gsmtap_cmd | ,
|  | "log gsmtap " | [HOSTNAME][(nonblocking-io|blocking-io|wq)],
|  | LOG_STR "Logging via GSMTAP\n" "Host name to send the GSMTAP logging to (UDP port 4729)\n" "Use non- | blocking,
|  | synchronous I/O(may lose msgs if UDP socket send buffer becomes full)(default)\n" "Use | blocking,
|  | synchronous I/O(only for debug purposes or when blocking is acceptable)\n" "Use Tx | workqueue,
|  | asynchronous I/O(may lose msgs if queue becomes full)\n" |
| ) |  |

References host::app_info, argc, argv, CFG_LOG_NODE, CMD_SUCCESS, CMD_WARNING, log_target::gsmtap_inst, gsmtap_inst_fd2(), gsmtap_source_set_nonblock(), gsmtap_source_using_wq(), GSMTAP_UDP_PORT, log_target::hostname, vty::index, log_add_target(), log_target_create_gsmtap(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_GSMTAP, vty_app_info::name, vty::node, osmo_sock_get_nonblock(), RET_WITH_UNLOCK, log_target::tgt_gsmtap, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [4/29]

DEFUN | ( | cfg_log_stderr | ,
|  | cfg_log_stderr_cmd | ,
|  | "log stderr " | [(nonblocking-io|blocking-io|wq)],
|  | LOG_STR "Logging via STDERR of the process\n" "Use non- | blocking,
|  | synchronous I/O(may lose msgs if file write buffer becomes full)(default)\n" "Use | blocking,
|  | synchronous I/O(only for debug purposes or when blocking is acceptable)\n" "Use Tx | workqueue,
|  | asynchronous I/O(may lose msgs if queue becomes full)\n" |
| ) |  |

References argc, argv, CFG_LOG_NODE, CMD_SUCCESS, CMD_WARNING, vty::index, log_add_target(), log_target_create_stderr(), log_target_file_set_nonblock(), log_target_file_switch_to_stream(), log_target_file_switch_to_wqueue(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_STDERR, vty::node, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [5/29]

DEFUN | ( | cfg_log_systemd_journal | ,
|  | cfg_log_systemd_journal_cmd | ,
|  | "log systemd-journal " | [raw],
|  | LOG_STR "Logging to systemd-journal\n" "Offload rendering of the meta information (location, category) to systemd\n" |
| ) |  |

References argc, CFG_LOG_NODE, CMD_SUCCESS, CMD_WARNING, vty::index, log_add_target(), log_target_create_systemd(), log_target_find(), log_target_systemd_set_raw(), log_tgt_mutex_lock, LOG_TGT_TYPE_SYSTEMD, vty::node, log_target::raw, RET_WITH_UNLOCK, log_target::sd_journal, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [6/29]

DEFUN | ( | cfg_no_log_alarms | ,
|  | cfg_no_log_alarms_cmd | ,
|  | "no log alarms" | ,
|  | NO_STR LOG_STR "Logging alarms to osmo_strrb\n" |
| ) |  |

References CMD_SUCCESS, CMD_WARNING, log_target_destroy(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_STRRB, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [7/29]

DEFUN | ( | cfg_no_log_file | ,
|  | cfg_no_log_file_cmd | ,
|  | "no log file FILENAME" | ,
|  | NO_STR LOG_STR "Logging to text file\n" "Filename\n" |
| ) |  |

References argv, CMD_SUCCESS, CMD_WARNING, log_target::fname, log_target_destroy(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_FILE, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [8/29]

DEFUN | ( | cfg_no_log_gsmtap | ,
|  | cfg_no_log_gsmtap_cmd | ,
|  | "no log gsmtap " | [HOSTNAME],
|  | NO_STR LOG_STR "Logging via GSMTAP\n" "Host name to send the GSMTAP logging to (UDP port 4729)\n" |
| ) |  |

References argc, argv, CMD_SUCCESS, CMD_WARNING, log_target::hostname, log_target_destroy(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_GSMTAP, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [9/29]

DEFUN | ( | cfg_no_log_stderr | ,
|  | cfg_no_log_stderr_cmd | ,
|  | "no log stderr" | ,
|  | NO_STR LOG_STR "Logging via STDERR of the process\n" |
| ) |  |

References CMD_SUCCESS, CMD_WARNING, log_target_destroy(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_STDERR, osmo_stderr_target, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [10/29]

DEFUN | ( | cfg_no_log_systemd_journal | ,
|  | cfg_no_log_systemd_journal_cmd | ,
|  | "no log systemd-journal" | ,
|  | NO_STR LOG_STR "Logging to systemd-journal\n" |
| ) |  |

References CMD_SUCCESS, CMD_WARNING, log_target_destroy(), log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_SYSTEMD, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [11/29]

DEFUN | ( | diable_logging | ,
|  | disable_logging_cmd | ,
|  | "logging disable" | ,
|  | LOGGING_STR "Disables logging to this vty\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, CMD_SUCCESS, telnet_connection::dbg, log_del_target(), vty::priv, and RET_WITH_UNLOCK.

## ◆ DEFUN() [12/29]

DEFUN | ( | enable_logging | ,
|  | enable_logging_cmd | ,
|  | "logging enable" | ,
|  | LOGGING_STR "Enables logging to this vty\n" |
| ) |  |

References CMD_SUCCESS, CMD_WARNING, telnet_connection::dbg, if(), log_add_target(), log_target_create_vty(), log_tgt_mutex_lock, vty::priv, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [13/29]

DEFUN | ( | logging_fltr_all | ,
|  | logging_fltr_all_cmd | ,
|  | "logging filter all (0|1)" | ,
|  | LOGGING_STR FILTER_STR "Do you want to log all messages?\n" "Only print messages matched by other filters\n" "Bypass filter and print all messages\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_all_filter(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [14/29]

DEFUN | ( | logging_level | ,
|  | logging_level_cmd | ,
|  | NULL | ,
|  | NULL |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, log_target::categories, CMD_SUCCESS, CMD_WARNING, log_category::enabled, level, log_cache_update(), log_parse_category(), log_parse_level(), log_category::loglevel, RET_WITH_UNLOCK, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [15/29]

DEFUN | ( | logging_level_force_all | ,
|  | logging_level_force_all_cmd | ,
|  | "logging level force-all " | LOG_LEVEL_ARGS,
|  | LOGGING_STR LEVEL_STR FORCE_ALL_STR | LOG_LEVEL_STRS
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, level, log_parse_level(), log_set_log_level(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [16/29]

DEFUN | ( | logging_level_set_all | ,
|  | logging_level_set_all_cmd | ,
|  | "logging level set-all " | LOG_LEVEL_ARGS,
|  | LOGGING_STR LEVEL_STR "Once-off set all categories to the given log level. There is no single command" " to take back these changes -- each category is set to the given | level,
|  | period.\n" | LOG_LEVEL_STRS
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, log_info::cat, log_target::categories, CMD_SUCCESS, log_category::enabled, level, log_cache_update(), log_parse_level(), log_category::loglevel, log_info_cat::name, log_info::num_cat, osmo_log_info, and RET_WITH_UNLOCK.

## ◆ DEFUN() [17/29]

DEFUN | ( | logging_prnt_cat | ,
|  | logging_prnt_cat_cmd | ,
|  | "logging print category (0|1)" | ,
|  | LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with category/subsystem name\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_print_category(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [18/29]

DEFUN | ( | logging_prnt_cat_hex | ,
|  | logging_prnt_cat_hex_cmd | ,
|  | "logging print category-hex (0|1)" | ,
|  | LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with category/subsystem nr in hex ('<000b>')\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_print_category_hex(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [19/29]

DEFUN | ( | logging_prnt_ext_timestamp | ,
|  | logging_prnt_ext_timestamp_cmd | ,
|  | "logging print extended-timestamp (0|1)" | ,
|  | LOGGING_STR "Log output settings\n" "Configure log message timestamping\n" "Don't prefix each log message\n" "Prefix each log message with current timestamp with YYYYMMDDhhmmssnnn\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_print_extended_timestamp(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [20/29]

DEFUN | ( | logging_prnt_file | ,
|  | logging_prnt_file_cmd | ,
|  | "logging print file (0|1|basename) " | [last],
|  | LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with the source file and line\n" "Prefix each log message with the source file's basename (strip leading paths) and line\n" "Log source file info at the end of a log line. If | omitted,
|  | log source file info just" " before the log text.\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argc, argv, CMD_SUCCESS, get_string_value(), LOG_FILENAME_POS_HEADER_END, LOG_FILENAME_POS_LINE_END, log_set_print_filename2(), log_set_print_filename_pos(), logging_print_file_args, and RET_WITH_UNLOCK.

## ◆ DEFUN() [21/29]

DEFUN | ( | logging_prnt_level | ,
|  | logging_prnt_level_cmd | ,
|  | "logging print level (0|1)" | ,
|  | LOGGING_STR "Log output settings\n" "Configure log message\n" "Don't prefix each log message\n" "Prefix each log message with the log level name\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_print_level(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [22/29]

DEFUN | ( | logging_prnt_tid | ,
|  | logging_prnt_tid_cmd | ,
|  | "logging print thread-id (0|1)" | ,
|  | LOGGING_STR "Log output settings\n" "Configure log message logging Thread ID\n" "Don't prefix each log message\n" "Prefix each log message with current Thread ID\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_print_tid(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [23/29]

DEFUN | ( | logging_prnt_timestamp | ,
|  | logging_prnt_timestamp_cmd | ,
|  | "logging timestamp (0|1)" | ,
|  | LOGGING_STR "Configure log message timestamping\n" "Don't prefix each log message\n" "Prefix each log message with current timestamp\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_print_timestamp(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [24/29]

DEFUN | ( | logging_set_category_mask | ,
|  | logging_set_category_mask_cmd | ,
|  | "logging set-log-mask MASK" | ,
|  | LOGGING_STR "Set the logmask of this logging target\n" "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' |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_parse_category_mask(), OSMO_STRINGIFY, OSMO_STRINGIFY_VAL, and RET_WITH_UNLOCK.

## ◆ DEFUN() [25/29]

DEFUN | ( | logging_use_clr | ,
|  | logging_use_clr_cmd | ,
|  | "logging color (0|1)" | ,
|  | LOGGING_STR "Configure color-printing for log messages\n" "Don't use color for printing messages\n" "Use color for printing messages\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, argv, CMD_SUCCESS, log_set_use_color(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [26/29]

DEFUN | ( | no_logging_level_force_all | ,
|  | no_logging_level_force_all_cmd | ,
|  | "no logging level force-all" | ,
|  | NO_STR LOGGING_STR LEVEL_STR | NO_FORCE_ALL_STR
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, CMD_SUCCESS, log_set_log_level(), and RET_WITH_UNLOCK.

## ◆ DEFUN() [27/29]

DEFUN | ( | show_alarms | ,
|  | show_alarms_cmd | ,
|  | "show alarms" | ,
|  | SHOW_STR SHOW_LOG_STR "Show the contents of the logging ringbuffer\n" |
| ) |  |

References CMD_SUCCESS, CMD_WARNING, log_target_find(), log_tgt_mutex_lock, LOG_TGT_TYPE_STRRB, osmo_strrb_elements(), osmo_strrb_get_nth(), log_target::rb, RET_WITH_UNLOCK, log_target::tgt_rb, VTY_NEWLINE, and vty_out().

## ◆ DEFUN() [28/29]

DEFUN | ( | show_logging_vty | ,
|  | show_logging_vty_cmd | ,
|  | "show logging vty" | ,
|  | SHOW_STR SHOW_LOG_STR "Show current logging configuration for this vty\n" |
| ) |  |

References ACQUIRE_VTY_LOG_TGT_WITH_LOCK, CMD_SUCCESS, osmo_log_info, RET_WITH_UNLOCK, and vty_print_logtarget().

## ◆ DEFUN() [29/29]

DEFUN | ( | vty_logp | ,
|  | vty_logp_cmd | ,
|  | NULL | ,
|  | NULL |
| ) |  |

References argc, argv, argv_concat(), CMD_SUCCESS, CMD_WARNING, level, log_parse_category(), log_parse_level(), LOGP, log_info::num_cat_user, osmo_log_info, VTY_NEWLINE, and vty_out().

## ◆ DEFUN_DEPRECATED()

DEFUN_DEPRECATED | ( | deprecated_logging_level_everything | ,
|  | deprecated_logging_level_everything_cmd | ,
|  | NULL | ,
|  | NULL |
| ) |  |

References CMD_SUCCESS, VTY_NEWLINE, and vty_out().

## ◆ gDEFUN() [1/2]

gDEFUN | ( | cfg_description | ,
|  | cfg_description_cmd | ,
|  | "description .TEXT" | ,
|  | "Save human-readable description of the object\n" "Text until the end of the line\n" |
| ) |  |

References argc, argv, argv_concat(), CMD_SUCCESS, CMD_WARNING, vty::index_sub, VTY_NEWLINE, and vty_out().

## ◆ gDEFUN() [2/2]

gDEFUN | ( | cfg_no_description | ,
|  | cfg_no_description_cmd | ,
|  | "no description" | ,
|  | NO_STR "Remove description of the object\n" |
| ) |  |

References CMD_SUCCESS, CMD_WARNING, vty::index_sub, VTY_NEWLINE, and vty_out().

## ◆ gen_logging_level_cmd_strs()

static void gen_logging_level_cmd_strs | ( | struct cmd_element * | cmd,
|  | const char * | level_args,
|  | const char * | level_strs
| ) |  |
| static

References add_category_strings(), assert_loginfo(), cmd_element::doc, LEVEL_STR, LOGGING_STR, OSMO_ASSERT, osmo_log_info, osmo_talloc_asprintf, cmd_element::string, and tall_log_ctx.

Referenced by logging_vty_add_cmds().

## ◆ gen_vty_logp_cmd_strs()

static void gen_vty_logp_cmd_strs | ( | struct cmd_element * | cmd | ) |
| static

References add_category_strings(), assert_loginfo(), cmd_element::doc, LOG_LEVEL_ARGS, LOG_LEVEL_STRS, OSMO_ASSERT, osmo_log_info, osmo_talloc_asprintf, cmd_element::string, and tall_log_ctx.

Referenced by logging_vty_add_cmds().

## ◆ log_deprecated_func()

static int log_deprecated_func | ( | struct cmd_element * | cmd,
|  | struct vty * | vty,
|  | int | argc,
|  | const char * | argv[]
| ) |  |
| static

References CMD_SUCCESS, cmd_element::string, VTY_NEWLINE, and vty_out().

Referenced by logging_vty_add_deprecated_subsys().

## ◆ log_target_create_vty()

struct log_target * log_target_create_vty | ( | struct vty * | vty | ) |

References _vty_output(), log_target_create(), log_target::output, log_target::tgt_vty, log_target::vty, and vty.

Referenced by DEFUN().

## ◆ logging_vty_add_cmds()

void logging_vty_add_cmds | ( | void |  | ) |

Register logging related commands to the VTY.

Call this once from your application if you want to support those commands.

References CFG_LOG_NODE, cfg_log_node, CONFIG_NODE, config_write_log(), EVERYTHING_STR, gen_logging_level_cmd_strs(), gen_vty_logp_cmd_strs(), install_lib_element(), install_lib_element_ve(), install_node(), LOG_LEVEL_ARGS, and LOG_LEVEL_STRS.

## ◆ logging_vty_add_deprecated_subsys()

void logging_vty_add_deprecated_subsys | ( | void * | ctx,
|  | const char * | name
| ) |  |

References cmd_element::attr, CFG_LOG_NODE, CMD_ATTR_DEPRECATED, cmd_element::doc, cmd_element::func, install_lib_element(), LEVEL_STR, log_deprecated_func(), LOG_LEVEL_ARGS, name, OSMO_ASSERT, and cmd_element::string.

## ◆ osmo_log_vty2tgt()

struct log_target * osmo_log_vty2tgt | ( | struct vty * | vty | ) |

Get log target associated to VTY console.

Parameters

  [in] | vty | Log target type

Returns
  Log target (if logging enabled), NULL otherwise Must be called with mutex osmo_log_tgt_mutex held, see log_tgt_mutex_lock.

References CFG_LOG_NODE, telnet_connection::dbg, if(), vty::index, vty::node, vty::priv, VTY_NEWLINE, and vty_out().

## ◆ vty_print_logtarget()

static void vty_print_logtarget | ( | struct vty * | vty,
|  | const struct log_info * | info,
|  | const struct log_target * | tgt
| ) |  |
| static

References log_info::cat, log_target::categories, log_info_cat::description, log_category::enabled, 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().

## Variable Documentation

## ◆ cfg_log_node

struct cmd_node cfg_log_node

Initial value:
= {
CFG_LOG_NODE,
"%s(config-log)# ",
1
}
CFG_LOG_NODE
@ CFG_LOG_NODE
Configure the logging.
Definition: command.h:81

Referenced by logging_vty_add_cmds().

## ◆ logging_print_file_args

const struct value_string logging_print_file_args[]
| static

Initial value:
= {
{ LOG_FILENAME_NONE, "0" },
{ LOG_FILENAME_PATH, "1" },
{ LOG_FILENAME_BASENAME, "basename" },
{ 0, NULL }
}
LOG_FILENAME_BASENAME
LOG_FILENAME_BASENAME
LOG_FILENAME_NONE
LOG_FILENAME_NONE
LOG_FILENAME_PATH
LOG_FILENAME_PATH

Referenced by config_write_log_single(), and DEFUN().