libosmocore 1.13.1.1-afb4 Osmocom core library

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
logging.h File Reference
Osmocom logging framework
`#include <stdio.h>`
`#include <stdint.h>`
`#include <stdarg.h>`
`#include <stdbool.h>`
`#include <osmocom/core/defs.h>`
`#include <osmocom/core/linuxlist.h>`

Go to the source code of this file.

## Data Structures
struct | log_category
| Configuration of single log category / sub-system. More...
struct | log_info_cat
| Information regarding one logging category. More...
struct | log_context
| Log context information, passed to filter. More...
struct | log_info
| Logging configuration, passed to log_init. More...
struct | log_target

## Macros
#define | DEBUG
#define | DEBUGP(ss, fmt, args...) LOGP(ss, LOGL_DEBUG, fmt, ##args)
| Log a debug message through the Osmocom logging framework. More...
#define | DEBUGPC(ss, fmt, args...) LOGPC(ss, LOGL_DEBUG, fmt, ##args)
#define | LOGP(ss, level, fmt, args...) LOGPSRC(ss, level, NULL, 0, fmt, ## args)
| Log a new message through the Osmocom logging framework. More...
#define | LOGPC(ss, level, fmt, args...)
| Continue a log message through the Osmocom logging framework. More...
#define | LOGPSRC(ss, level, caller_file, caller_line, fmt, args...) LOGPSRCC(ss, level, caller_file, caller_line, 0, fmt, ##args)
| Log through the Osmocom logging framework with explicit source. More...
#define | LOGPSRCC(ss, level, caller_file, caller_line, cont, fmt, args...)
| Log through the Osmocom logging framework with explicit source. More...
#define | LOGL_DEBUG 1
| different log levels More...
#define | LOGL_INFO 3
| general information More...
#define | LOGL_NOTICE 5
| abnormal/unexpected condition More...
#define | LOGL_ERROR 7
| error condition, requires user action More...
#define | LOGL_FATAL 8
| fatal, program aborted More...
#define | DLGLOBAL -1
| global logging More...
#define | DLLAPD -2
| LAPD implementation. More...
#define | DLINP -3
| (A-bis) Input sub-system More...
#define | DLMUX -4
| Osmocom Multiplex (Osmux) More...
#define | DLMI -5
| ISDN-layer below input sub-system. More...
#define | DLMIB -6
| ISDN layer B-channel. More...
#define | DLSMS -7
| SMS sub-system. More...
#define | DLCTRL -8
| Control Interface. More...
#define | DLGTP -9
| GTP (GPRS Tunneling Protocol. More...
#define | DLSTATS -10
| Statistics. More...
#define | DLGSUP -11
| Generic Subscriber Update Protocol. More...
#define | DLOAP -12
| Osmocom Authentication Protocol. More...
#define | DLSS7 -13
| Osmocom SS7. More...
#define | DLSCCP -14
| Osmocom SCCP. More...
#define | DLSUA -15
| Osmocom SUA. More...
#define | DLM3UA -16
| Osmocom M3UA. More...
#define | DLMGCP -17
| Osmocom MGCP. More...
#define | DLJIBUF -18
| Osmocom Jitter Buffer. More...
#define | DLRSPRO -19
| Osmocom Remote SIM Protocol. More...
#define | DLNS -20
| Osmocom NS layer. More...
#define | DLBSSGP -21
| Osmocom BSSGP layer. More...
#define | DLNSDATA -22
| Osmocom NS layer data pdus. More...
#define | DLNSSIGNAL -23
| Osmocom NS layer signal pdus. More...
#define | DLIUUP -24
| Osmocom IuUP layer. More...
#define | DLPFCP -25
| Osmocom Packet Forwarding Control Protocol. More...
#define | DLCSN1 -26
| CSN.1 (Concrete Syntax Notation 1) codec. More...
#define | DLM2PA -27
| Osmocom M2PA (libosmo-sigtran) More...
#define | DLM2UA -28
| Reserved for future Osmocom M2UA (libosmo-sigtran) More...
#define | DLIO -29
| Osmocom IO sub-system. More...
#define | DLTCAP -30
| Osmocom TCAP. More...
#define | OSMO_NUM_DLIB 30
| Number of logging sub-systems in libraries. More...
#define | OSMO_LOGCOLOR_NORMAL NULL
#define | OSMO_LOGCOLOR_RED "\033[1;31m"
#define | OSMO_LOGCOLOR_GREEN "\033[1;32m"
#define | OSMO_LOGCOLOR_YELLOW "\033[1;33m"
#define | OSMO_LOGCOLOR_BLUE "\033[1;34m"
#define | OSMO_LOGCOLOR_PURPLE "\033[1;35m"
#define | OSMO_LOGCOLOR_CYAN "\033[1;36m"
#define | OSMO_LOGCOLOR_DARKRED "\033[31m"
#define | OSMO_LOGCOLOR_DARKGREEN "\033[32m"
#define | OSMO_LOGCOLOR_DARKYELLOW "\033[33m"
#define | OSMO_LOGCOLOR_DARKBLUE "\033[34m"
#define | OSMO_LOGCOLOR_DARKPURPLE "\033[35m"
#define | OSMO_LOGCOLOR_DARKCYAN "\033[36m"
#define | OSMO_LOGCOLOR_DARKGREY "\033[1;30m"
#define | OSMO_LOGCOLOR_GREY "\033[37m"
#define | OSMO_LOGCOLOR_BRIGHTWHITE "\033[1;37m"
#define | OSMO_LOGCOLOR_END "\033[0;m"
#define | LOG_MAX_CTX _LOG_CTX_COUNT
| Maximum number of logging contexts. More...
#define | LOG_MAX_FILTERS _LOG_FLT_COUNT
| Maximum number of logging filters. More...
#define | LOG_FILTER_ALL (1<<LOG_FLT_ALL)
| Compatibility with older libosmocore versions. More...
#define | GPRS_CTX_NSVC LOG_CTX_GB_NSVC
| Compatibility with older libosmocore versions. More...
#define | GPRS_CTX_BVC LOG_CTX_GB_BVC
| Compatibility with older libosmocore versions. More...
#define | OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE_LOG_TARGET OSMO_DEPRECATED_OUTSIDE("Accessing struct log_target members directly is deprecated")
| structure representing a logging target More...
#define | LOG_MTX_DEBUG 0
#define | log_tgt_mutex_lock() log_tgt_mutex_lock_impl()
#define | log_tgt_mutex_unlock() log_tgt_mutex_unlock_impl()

## Typedefs
typedef int | log_filter(const struct log_context *ctx, struct log_target *target)
| Log filter function. More...
typedef void | log_print_filters(struct vty *vty, const struct log_info *info, const struct log_target *tgt)
typedef void | log_save_filters(struct vty *vty, const struct log_info *info, const struct log_target *tgt)

## Enumerations
enum | log_ctx_index { LOG_CTX_GB_NSVC , LOG_CTX_GB_BVC , LOG_CTX_BSC_SUBSCR , LOG_CTX_VLR_SUBSCR , LOG_CTX_L1_SAPI , LOG_CTX_GB_NSE , _LOG_CTX_COUNT }
| Indexes to indicate the object currently acted upon. More...
enum | log_filter_index { LOG_FLT_ALL , LOG_FLT_GB_NSVC , LOG_FLT_GB_BVC , LOG_FLT_BSC_SUBSCR , LOG_FLT_VLR_SUBSCR , LOG_FLT_L1_SAPI , LOG_FLT_GB_NSE , _LOG_FLT_COUNT }
| Indexes to indicate objects that should be logged. More...
enum | log_target_type { LOG_TGT_TYPE_VTY , LOG_TGT_TYPE_SYSLOG , LOG_TGT_TYPE_FILE , LOG_TGT_TYPE_STDERR , LOG_TGT_TYPE_STRRB , LOG_TGT_TYPE_GSMTAP , LOG_TGT_TYPE_SYSTEMD , LOG_TGT_TYPE_EMSCRIPTEN }
| Type of logging target. More...
enum | log_filename_type { LOG_FILENAME_NONE , LOG_FILENAME_PATH , LOG_FILENAME_BASENAME }
| Whether/how to log the source filename (and line number). More...
enum | log_filename_pos { LOG_FILENAME_POS_HEADER_END , LOG_FILENAME_POS_LINE_END }
| Where on a log line source file and line should be logged. More...

## Functions
void | osmo_vlogp (int subsys, int level, const char *file, int line, int cont, const char *format, va_list ap)
| vararg version of logging function More...
void | logp (int subsys, const char *file, int line, int cont, const char *format,...)
| logging function used by DEBUGP() macro More...
void | logp2 (int subsys, unsigned int level, const char *file, int line, int cont, const char *format,...)
| logging function used by LOGP() macro More...
void void | logp_stub (const char *file, int line, int cont, const char *format,...)
int | log_init (const struct log_info *inf, void *ctx)
| Initialize the Osmocom logging core. More...
void | log_fini (void)
int | log_check_level (int subsys, unsigned int level)
| Check whether a log entry will be generated. More...
void | log_reset_context (void)
| Reset (clear) the logging context. More...
int | log_set_context (uint8_t ctx_nr, void *value)
| Set the logging context. More...
void * | log_get_context (const struct log_context *ctx, uint8_t ctx_nr)
| Get the logging context. More...
void | log_set_all_filter (struct log_target *target, int all)
| Enable/disable the LOG_FLT_ALL log filter. More...
bool | log_get_filter (const struct log_target *target, int log_filter_index)
| Query whether a log filter is enabled or disabled. More...
int | log_set_filter (struct log_target *target, int log_filter_index, bool enable)
| Enable/disable a log filter. More...
void * | log_get_filter_data (const struct log_target *target, int log_filter_index)
| Obtain data associated to a log filter. More...
int | log_set_filter_data (struct log_target *target, int log_filter_index, void *data)
| Set data associated to a log filter. More...
int | log_cache_enable (void)
| Enable the log level lookup cache to bypass string formatting and other code for log statements which are not actually enabled/needed by any existing log target. More...
void | log_cache_update (int mapped_subsys, uint8_t enabled, uint8_t level)
| Updates single cache entry, caller must hold osmo_log_tgt_mutex. More...
void | log_set_use_color (struct log_target *target, int use_color)
| Enable or disable the use of colored output. More...
void | log_set_print_extended_timestamp (struct log_target *target, int print_timestamp)
| Enable or disable printing of extended timestamps while logging. More...
void | log_set_print_timestamp (struct log_target *target, int print_timestamp)
| Enable or disable printing of timestamps while logging. More...
void | log_set_print_tid (struct log_target *target, int print_tid)
| Enable or disable printing of timestamps while logging. More...
void | log_set_print_filename (struct log_target *target, int print_filename)
| Use log_set_print_filename2() instead. More...
void | log_set_print_filename2 (struct log_target *target, enum log_filename_type lft)
| Enable or disable printing of the filename while logging. More...
void | log_set_print_filename_pos (struct log_target *target, enum log_filename_pos pos)
| Set the position where on a log line the source file info should be logged. More...
void | log_set_print_category (struct log_target *target, int print_category)
| Enable or disable printing of the category name. More...
void | log_set_print_category_hex (struct log_target *target, int print_category_hex)
| Enable or disable printing of the category number in hex ('<000b>'). More...
void | log_set_print_level (struct log_target *target, int print_level)
| Enable or disable printing of the log level name. More...
void | log_set_log_level (struct log_target *target, int log_level)
| Set the global log level for a given log target. More...
void | log_parse_category_mask (struct log_target *target, const char *_mask)
| parse the log category mask More...
const char * | log_category_name (int subsys)
int | log_parse_level (const char *lvl)
| Parse a human-readable log level into a numeric value. More...
const char * | log_level_str (unsigned int lvl)
| convert a numeric log level into human-readable string More...
int | log_parse_category (const char *category)
| parse a human-readable log category into numeric form More...
void | log_set_category_filter (struct log_target *target, int category, int enable, int level)
| Set a category filter on a given log target. More...
struct log_target * | log_target_create (void)
| Create a new log target skeleton. More...
void | log_target_destroy (struct log_target *target)
| Unregister, close and delete a log target. More...
struct log_target * | log_target_create_stderr (void)
| Create the STDERR log target. More...
struct log_target * | log_target_create_file (const char *fname)
| Create a new file-based log target using a stream. More...
struct log_target * | log_target_create_syslog (const char *ident, int option, int facility)
| Create a new logging target for syslog logging. More...
struct log_target * | log_target_create_gsmtap (const char *host, uint16_t port, const char *ident, bool ofd_wq_mode, bool add_sink)
| Create a new logging target for GSMTAP logging. More...
struct log_target * | log_target_create_systemd (bool raw)
| Create a new logging target for systemd journal logging. More...
struct log_target * | log_target_create_emscripten (void)
| Create a new logging target for JS callback logging (uses `on_log`) More...
void | log_target_systemd_set_raw (struct log_target *target, bool raw)
| Change meta information handling of an existing logging target. More...
int | log_target_file_reopen (struct log_target *target)
| close and re-open a log file (for log file rotation) More...
int | log_target_file_switch_to_stream (struct log_target *target)
| switch from non-blocking/write-queue to blocking + buffered stream output More...
int | log_target_file_switch_to_wqueue (struct log_target *target)
| switch from blocking + buffered file output to non-blocking write-queue based output. More...
int | log_target_file_get_nonblock (const struct log_target *target)
| Find whether the log target fd is configured as non-blocking (see sockopt O_NONBLOCK). More...
int | log_target_file_set_nonblock (struct log_target *target, int on)
| Set the log target fd as non-blocking (see sockopt O_NONBLOCK). More...
int | log_targets_reopen (void)
| close and re-open all log files (for log file rotation) More...
void | log_add_target (struct log_target *target)
| Register a new log target with the logging core. More...
void | log_del_target (struct log_target *target)
| Unregister a log target from the logging core. More...
struct log_target * | log_target_find (enum log_target_type type, const char *fname)
| Find a registered log target. More...
void | log_enable_multithread (void)
| Enable multithread support (mutex) in libosmocore logging system. More...
void | log_tgt_mutex_lock_impl (void)
| Acquire the osmo_log_tgt_mutex. More...
void | log_tgt_mutex_unlock_impl (void)
| Release the osmo_log_tgt_mutex. More...

## Variables
struct log_info * | osmo_log_info