20 #ifdef LIBOSMOCORE_NO_LOGGING 30 #define DEBUGP(ss, fmt, args...) LOGP(ss, LOGL_DEBUG, fmt, ##args) 31 #define DEBUGPC(ss, fmt, args...) LOGPC(ss, LOGL_DEBUG, fmt, ##args) 33 #define DEBUGP(xss, fmt, args...) 34 #define DEBUGPC(ss, fmt, args...) 39 int cont,
const char *format, va_list ap);
49 #define LOGP(ss, level, fmt, args...) \ 50 LOGPSRC(ss, level, NULL, 0, fmt, ## args) 58 #ifndef LIBOSMOCORE_NO_LOGGING 59 #define LOGPC(ss, level, fmt, args...) \ 61 if (!osmo_log_info) { \ 62 logp_stub(__FILE__, __LINE__, 1, fmt, ##args); \ 65 if (log_check_level(ss, level)) \ 66 logp2(ss, level, __FILE__, __LINE__, 1, fmt, ##args); \ 69 #define LOGPC(ss, level, fmt, args...) 84 #define LOGPSRC(ss, level, caller_file, caller_line, fmt, args...) \ 85 LOGPSRCC(ss, level, caller_file, caller_line, 0, fmt, ##args) 100 #ifndef LIBOSMOCORE_NO_LOGGING 101 #define LOGPSRCC(ss, level, caller_file, caller_line, cont, fmt, args...) \ 103 if (!osmo_log_info) { \ 105 logp_stub(caller_file, caller_line, cont, fmt, ##args); \ 107 logp_stub(__FILE__, __LINE__, cont, fmt, ##args); \ 110 if (log_check_level(ss, level)) {\ 112 logp2(ss, level, caller_file, caller_line, cont, fmt, ##args); \ 114 logp2(ss, level, __FILE__, __LINE__, cont, fmt, ##args); \ 118 #define LOGPSRCC(ss, level, caller_file, caller_line, cont, fmt, args...) 124 #define LOGL_NOTICE 5 151 #define DLNSSIGNAL -23 158 #define OSMO_NUM_DLIB 29 161 #define OSMO_LOGCOLOR_NORMAL NULL 162 #define OSMO_LOGCOLOR_RED "\033[1;31m" 163 #define OSMO_LOGCOLOR_GREEN "\033[1;32m" 164 #define OSMO_LOGCOLOR_YELLOW "\033[1;33m" 165 #define OSMO_LOGCOLOR_BLUE "\033[1;34m" 166 #define OSMO_LOGCOLOR_PURPLE "\033[1;35m" 167 #define OSMO_LOGCOLOR_CYAN "\033[1;36m" 168 #define OSMO_LOGCOLOR_DARKRED "\033[31m" 169 #define OSMO_LOGCOLOR_DARKGREEN "\033[32m" 170 #define OSMO_LOGCOLOR_DARKYELLOW "\033[33m" 171 #define OSMO_LOGCOLOR_DARKBLUE "\033[34m" 172 #define OSMO_LOGCOLOR_DARKPURPLE "\033[35m" 173 #define OSMO_LOGCOLOR_DARKCYAN "\033[36m" 174 #define OSMO_LOGCOLOR_DARKGREY "\033[1;30m" 175 #define OSMO_LOGCOLOR_GREY "\033[37m" 176 #define OSMO_LOGCOLOR_BRIGHTWHITE "\033[1;37m" 177 #define OSMO_LOGCOLOR_END "\033[0;m" 221 #define LOG_MAX_CTX _LOG_CTX_COUNT 223 #define LOG_MAX_FILTERS _LOG_FLT_COUNT 231 #define LOG_FILTER_ALL (1<<LOG_FLT_ALL) 233 #define GPRS_CTX_NSVC LOG_CTX_GB_NSVC 235 #define GPRS_CTX_BVC LOG_CTX_GB_BVC 384 unsigned int level,
const char *
file,
int line,
385 int cont,
const char *format, va_list ap);
398 void logp2(
int subsys,
unsigned int level,
const char *file,
399 int line,
int cont,
const char *format, ...)
401 void logp_stub(const
char *file,
int line,
int cont, const
char *format, ...);
427 const
char *
log_level_str(
unsigned int lvl) OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE;
430 int enable,
int level);
459 #define LOG_MTX_DEBUG 0 462 #define log_tgt_mutex_lock() do { fprintf(stderr, "[%lu] %s:%d [%s] lock\n", pthread_self(), __FILE__, __LINE__, __func__); log_tgt_mutex_lock_impl(); } while (0) 463 #define log_tgt_mutex_unlock() do { fprintf(stderr, "[%lu] %s:%d [%s] unlock\n", pthread_self(), __FILE__, __LINE__, __func__); log_tgt_mutex_unlock_impl(); } while (0) 465 #define log_tgt_mutex_lock() log_tgt_mutex_lock_impl() 466 #define log_tgt_mutex_unlock() log_tgt_mutex_unlock_impl() struct log_info * osmo_log_info
Definition: logging.c:87
void log_set_print_category_hex(struct log_target *target, int)
Enable or disable printing of the category number in hex ('<000b>').
Definition: logging.c:934
Definition: logging.h:295
Information regarding one logging category.
Definition: logging.h:186
int filter_map
Internal data for filtering.
Definition: logging.h:304
int log_parse_level(const char *lvl) OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE
Parse a human-readable log level into a numeric value.
Definition: logging.c:343
#define OSMO_DEPRECATED(text)
Set the deprecated attribute with a message.
Definition: defs.h:41
int log_parse_category(const char *category)
parse a human-readable log category into numeric form
Definition: logging.c:361
const char * name
name of category
Definition: logging.h:187
VTY logging.
Definition: logging.h:277
log_save_filters * save_fn
filter saving function
Definition: logging.h:270
Definition: logging.h:217
log_filename_type
Whether/how to log the source filename (and line number).
Definition: logging.h:287
void log_set_print_tid(struct log_target *target, int)
Enable or disable printing of timestamps while logging.
Definition: logging.c:877
bool print_level
Definition: logging.h:388
void * rb
Definition: logging.h:348
char subsys[16]
logging sub-system
Definition: gsmtap.h:129
void log_set_print_timestamp(struct log_target *target, int)
Enable or disable printing of timestamps while logging.
Definition: logging.c:855
const char * fname
Definition: logging.h:333
void logp(int subsys, const char *file, int line, int cont, const char *format,...) OSMO_DEPRECATED("Use DEBUGP* macros instead")
logging function used by DEBUGP() macro
Definition: logging.c:743
void log_set_print_filename(struct log_target *target, int) OSMO_DEPRECATED("Use log_set_print_filename2() instead")
Use log_set_print_filename2() instead.
Definition: logging.c:891
Configuration of single log category / sub-system.
Definition: logging.h:180
void log_set_print_extended_timestamp(struct log_target *target, int)
Enable or disable printing of extended timestamps while logging.
Definition: logging.c:868
log_ctx_index
Indexes to indicate the object currently acted upon.
Definition: logging.h:196
Definition: logging.h:198
#define OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE
Definition: defs.h:48
Definition: logging.h:289
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.
Definition: logging_gsmtap.c:130
Definition: logging.h:212
uint8_t enabled
is this category enabled or not
Definition: logging.h:191
void log_set_print_filename2(struct log_target *target, enum log_filename_type lft)
Enable or disable printing of the filename while logging.
Definition: logging.c:903
log_filter_index
Indexes to indicate objects that should be logged.
Definition: logging.h:209
Definition: logging.h:210
int log_set_context(uint8_t ctx, void *value)
Set the logging context.
Definition: logging.c:816
syslog based logging
Definition: logging.h:278
const char * ident
Definition: logging.h:353
Definition: logging.h:201
Definition: logging.h:202
Definition: logging.h:213
General definitions that are meant to be included from header files.
bool raw
Definition: logging.h:358
struct log_target * log_target_create_syslog(const char *ident, int option, int facility)
log_target_type
Type of logging target.
Definition: logging.h:276
void log_target_destroy(struct log_target *target)
Unregister, close and delete a log target.
Definition: logging.c:1320
#define DEBUGP(ss, fmt, args...)
Log a debug message through the Osmocom logging framework.
Definition: logging.h:30
void * vty
Definition: logging.h:344
#define LOG_MAX_FILTERS
Maximum number of logging filters.
Definition: logging.h:223
write Write running configuration to or terminal n Write configuration to the file(same as write file)\n") ALIAS(config_write_file
one gsmtap instance
Definition: gsmtap_util.c:50
uint8_t enabled
is logging enabled?
Definition: logging.h:182
void log_target_systemd_set_raw(struct log_target *target, bool raw)
Change meta information handling of an existing logging target.
Definition: logging_systemd.c:105
enum log_filename_type print_filename2
Definition: logging.h:392
int facility
Definition: logging.h:340
int log_target_file_switch_to_wqueue(struct log_target *tgt)
switch from blocking + buffered file output to non-blocking write-queue based output.
Definition: logging.c:1187
uint8_t level
logging level
Definition: gsmtap.h:126
unsigned int print_category
should log messages be prefixed with a category name?
Definition: logging.h:322
void log_add_target(struct log_target *target)
Register a new log target with the logging core.
Definition: logging.c:786
int log_filter(const struct log_context *ctx, struct log_target *target)
Log filter function.
Definition: logging.h:242
osmo_strrb-backed logging
Definition: logging.h:281
write queue instance
Definition: write_queue.h:30
Definition: logging.h:214
int priority
Definition: logging.h:339
void log_enable_multithread(void)
Enable multithread support (mutex) in libosmocore logging system.
Definition: logging.c:107
text file logging
Definition: logging.h:279
Definition: logging.h:288
bool print_category_hex
Definition: logging.h:390
void log_del_target(struct log_target *target)
Unregister a log target from the logging core.
Definition: logging.c:794
void(* raw_output)(struct log_target *target, int subsys, unsigned int level, const char *file, int line, int cont, const char *format, va_list ap)
alternative call-back function to which the logging framework passes the unfortmatted input arguments...
Definition: logging.h:383
struct osmo_wqueue * wqueue
Definition: logging.h:335
FILE * out
Definition: logging.h:332
enum log_filename_pos print_filename_pos
Definition: logging.h:394
Definition: logging.h:216
void log_set_all_filter(struct log_target *target, int)
Enable the LOG_FLT_ALL log filter.
Definition: logging.c:834
stderr logging
Definition: logging.h:280
void log_save_filters(struct vty *vty, const struct log_info *info, const struct log_target *tgt)
Definition: logging.h:253
unsigned int print_tid
should log messages be prefixed with the logger Thread ID?
Definition: logging.h:318
struct gsmtap_inst * gsmtap_inst
Definition: logging.h:352
Simple doubly linked list implementation.
void log_print_filters(struct vty *vty, const struct log_info *info, const struct log_target *tgt)
Definition: logging.h:249
unsigned int print_filename
DEPRECATED: use print_filename2 instead.
Definition: logging.h:320
(double) linked list header structure
Definition: linuxlist.h:46
void log_set_use_color(struct log_target *target, int)
Enable or disable the use of colored output.
Definition: logging.c:846
const char * color
color string for cateyory
Definition: logging.h:188
struct log_target * log_target_create_systemd(bool raw)
Create a new logging target for systemd journal logging.
Definition: logging_systemd.c:86
Definition: logging.h:211
void log_set_print_category(struct log_target *target, int)
Enable or disable printing of the category name.
Definition: logging.c:925
log_filter * filter_fn
Definition: logging.h:260
Definition: logging.h:199
int log_target_file_reopen(struct log_target *tgt)
close and re-open a log file (for log file rotation)
Definition: logging.c:1370
Definition: logging.h:200
int log_init(const struct log_info *inf, void *talloc_ctx)
Initialize the Osmocom logging core.
Definition: logging.c:1435
void void logp_stub(const char *file, int line, int cont, const char *format,...)
Definition: logging.c:773
struct log_target * log_target_create_stderr(void)
Create the STDERR log target.
Definition: logging.c:1086
const char * log_level_str(unsigned int lvl) OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE
convert a numeric log level into human-readable string
Definition: logging.c:352
struct log_category * categories
logging categories
Definition: logging.h:309
uint8_t loglevel
global log level
Definition: logging.h:312
void log_tgt_mutex_lock_impl(void)
Acquire the osmo_log_tgt_mutex.
Definition: logging.c:117
Definition: logging.h:290
void log_set_category_filter(struct log_target *target, int category, int enable, int level)
Set a category filter on a given log target.
Definition: logging.c:965
void log_tgt_mutex_unlock_impl(void)
Release the osmo_log_tgt_mutex.
Definition: logging.c:133
GSMTAP network logging.
Definition: logging.h:282
void log_fini(void)
Definition: logging.c:1494
int log_check_level(int subsys, unsigned int level)
Check whether a log entry will be generated.
Definition: logging.c:1513
uint8_t loglevel
configured log-level
Definition: logging.h:181
enum gsm0808_assignment_requirement __attribute__
fls64 - find last set bit in a 64-bit word : the word to search
Definition: log2.h:61
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.
Definition: logging.c:914
Definition: logging.h:215
Definition: logging.h:203
struct log_target * log_target_create_file(const char *fname)
Create a new file-based log target using non-blocking write_queue.
Definition: logging.c:1244
log_filename_pos
Where on a log line source file and line should be logged.
Definition: logging.h:294
Logging configuration, passed to log_init.
Definition: logging.h:258
uint8_t type
see GSMTAP_TYPE_*
Definition: gsmtap.h:122
void log_parse_category_mask(struct log_target *target, const char *mask)
parse the log category mask
Definition: logging.c:384
unsigned int print_timestamp
should log messages be prefixed with a timestamp?
Definition: logging.h:316
Definition: logging.h:197
log_print_filters * print_fn
filter saving function
Definition: logging.h:272
unsigned int num_cat_user
total number of user categories (not library)
Definition: logging.h:267
const char * log_category_name(int subsys)
Definition: logging.c:457
Log context information, passed to filter.
Definition: logging.h:226
const struct log_info_cat * cat
per-category information
Definition: logging.h:263
unsigned int use_color
should color be used when printing log messages?
Definition: logging.h:314
unsigned int print_ext_timestamp
should log messages be prefixed with an extended timestamp?
Definition: logging.h:324
struct log_target * log_target_create(void)
Create a new log target skeleton.
Definition: logging.c:1044
void log_set_print_level(struct log_target *target, int)
Enable or disable printing of the log level name.
Definition: logging.c:945
const char * hostname
Definition: logging.h:354
struct log_target * log_target_find(enum log_target_type type, const char *fname)
Find a registered log target.
Definition: logging.c:1295
structure representing a logging target
Definition: logging.h:300
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
Definition: logging.c:708
void log_set_log_level(struct log_target *target, int log_level)
Set the global log level for a given log target.
Definition: logging.c:954
int log_target_file_switch_to_stream(struct log_target *tgt)
switch from non-blocking/write-queue to blocking + buffered stream output
Definition: logging.c:1135
void log_reset_context(void)
Reset (clear) the logging context.
Definition: logging.c:800
#define LOG_MAX_CTX
Maximum number of logging contexts.
Definition: logging.h:221
systemd journal logging
Definition: logging.h:283
uint8_t loglevel
currently selected log-level
Definition: logging.h:190
unsigned int num_cat
total number of categories
Definition: logging.h:265
void logp2(int subsys, unsigned int level, const char *file, int line, int cont, const char *format,...) __attribute__((format(printf
logging function used by LOGP() macro
Definition: logging.c:760
int log_targets_reopen(void)
close and re-open all log files (for log file rotation)
Definition: logging.c:1405
Definition: logging.h:296
const char * description
description text
Definition: logging.h:189