|
libosmocore 1.11.0.52-28973f
Osmocom core library
|
Debugging/Logging support code. More...
#include "config.h"#include <stdarg.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <unistd.h>#include <time.h>#include <sys/time.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <errno.h>#include <pthread.h>#include <osmocom/core/talloc.h>#include <osmocom/core/utils.h>#include <osmocom/core/logging.h>#include <osmocom/core/timer.h>#include <osmocom/core/thread.h>#include <osmocom/core/select.h>#include <osmocom/core/write_queue.h>#include <osmocom/core/gsmtap_util.h>#include <osmocom/vty/logging.h>Macros | |
| #define | TRACE(probe) |
| #define | TRACE_ENABLED(probe) (0) |
| #define | MAX_LOG_SIZE 4096 |
| #define | LOG_WQUEUE_LEN 156 |
| #define | INT2IDX(x) (-1*(x)-1) |
Functions | |
| osmo_static_assert (_LOG_CTX_COUNT<=ARRAY_SIZE(((struct log_context *) NULL) ->ctx), enum_logging_ctx_items_fit_in_struct_log_context) | |
| osmo_static_assert (_LOG_FLT_COUNT<=ARRAY_SIZE(((struct log_target *) NULL) ->filter_data), enum_logging_filters_fit_in_log_target_filter_data) | |
| osmo_static_assert (_LOG_FLT_COUNT<=8 *sizeof(((struct log_target *) NULL) ->filter_map), enum_logging_filters_fit_in_log_target_filter_map) | |
| LLIST_HEAD (osmo_log_target_list) | |
| static void | log_cache_update_all (void) |
| Updates cache for all targets for all categies, caller must hold osmo_log_tgt_mutex. 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... | |
| static bool | log_cache_check (int mapped_subsys, int level) |
| Queries log level cache. 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... | |
| void | assert_loginfo (const char *src) |
| static int | subsys_lib2index (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_parse_category_mask (struct log_target *target, const char *_mask) |
| parse the log category mask More... | |
| static const char * | color (int subsys) |
| static const char * | level_color (int level) |
| const char * | log_category_name (int subsys) |
| static const char * | const_basename (const char *path) |
| static int | _output_buf (char *buf, int buf_len, struct log_target *target, unsigned int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap) |
| main output formatting function for log lines. More... | |
| static void | _output (struct log_target *target, unsigned int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap) |
| static int | map_subsys (int subsys) |
| static bool | should_log_to_target (struct log_target *tar, int subsys, int level) |
| 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,...) |
| 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... | |
| 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_set_all_filter (struct log_target *target, int all) |
| Enable the LOG_FLT_ALL log filter. 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_timestamp (struct log_target *target, int print_timestamp) |
| Enable or disable printing of timestamps while logging. 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_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_set_category_filter (struct log_target *target, int category, int enable, int level) |
| Set a category filter on a given log target. More... | |
| static int | _file_wq_write_cb (struct osmo_fd *ofd, struct msgb *msg) |
| static void | _file_output_stream (struct log_target *target, unsigned int level, const char *log) |
| static void | _file_raw_output (struct log_target *target, int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap) |
| struct log_target * | log_target_create (void) |
| Create a new log target skeleton. More... | |
| struct log_target * | log_target_create_stderr (void) |
| Create the STDERR log target. More... | |
| struct log_target * | log_target_create_file_stream (const char *fname) |
| Create a new file-based log target using buffered, blocking stream output. 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... | |
| struct log_target * | log_target_create_file (const char *fname) |
| Create a new file-based log target using non-blocking write_queue. More... | |
| struct log_target * | log_target_find (enum log_target_type type, const char *fname) |
| Find a registered log target. More... | |
| void | log_target_destroy (struct log_target *target) |
| Unregister, close and delete a log 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_targets_reopen (void) |
| close and re-open all log files (for log file rotation) 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... | |
| 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... | |
Variables | |
| struct log_info * | osmo_log_info |
| static struct log_context | log_context |
| void * | tall_log_ctx = NULL |
| static __thread long int | logging_tid |
| static volatile uint8_t * | log_level_lookup_cache |
| One global copy that contains the union of log levels for all targets for all categories, used for quick lock free checks of log targets. More... | |
| static pthread_mutex_t | osmo_log_tgt_mutex |
| This mutex must be held while using osmo_log_target_list or any of its log_targets in a multithread program. More... | |
| static bool | osmo_log_tgt_mutex_on = false |
| const struct value_string | loglevel_strs [] |
| static const struct log_info_cat | internal_cat [OSMO_NUM_DLIB] |
| static const struct value_string | level_colors [] |
Debugging/Logging support code.