12 #include <osmocom/core/linuxlist.h>
17 #define LOG_MAX_FILTERS 8
22 #define DEBUGP(ss, fmt, args...) \
24 if (log_check_level(ss, LOGL_DEBUG)) \
25 logp(ss, __FILE__, __LINE__, 0, fmt, ## args); \
28 #define DEBUGPC(ss, fmt, args...) \
30 if (log_check_level(ss, LOGL_DEBUG)) \
31 logp(ss, __FILE__, __LINE__, 1, fmt, ## args); \
35 #define DEBUGP(xss, fmt, args...)
36 #define DEBUGPC(ss, fmt, args...)
40 void osmo_vlogp(
int subsys,
int level,
const char *file,
int line,
41 int cont,
const char *format, va_list ap);
43 void logp(
int subsys,
const char *file,
int line,
int cont,
const char *format, ...) __attribute__ ((format (printf, 5, 6)));
51 #define LOGP(ss, level, fmt, args...) \
53 if (log_check_level(ss, level)) \
54 logp2(ss, level, __FILE__, __LINE__, 0, fmt, ##args); \
63 #define LOGPC(ss, level, fmt, args...) \
65 if (log_check_level(ss, level)) \
66 logp2(ss, level, __FILE__, __LINE__, 1, fmt, ##args); \
76 #define LOG_FILTER_ALL 0x0001
89 #define OSMO_NUM_DLIB 10
119 typedef void log_print_filters(
struct vty *vty,
123 typedef void log_save_filters(
struct vty *vty,
140 log_save_filters *save_fn;
142 log_print_filters *print_fn;
213 void logp2(
int subsys,
unsigned int level,
const char *file,
214 int line,
int cont,
const char *format, ...)
215 __attribute__ ((format (printf, 6, 7)));
237 int enable,
int level);
244 struct
log_target *log_target_create_syslog(const
char *ident,
int option,
257 extern struct
llist_head osmo_log_target_list;
Information regarding one logging category.
Definition: logging.h:97
int filter_map
Internal data for filtering.
Definition: logging.h:159
void log_set_all_filter(struct log_target *target, int)
Enable the LOG_FILTER_ALL log filter.
Definition: logging.c:449
int log_parse_level(const char *lvl)
Parse a human-readable log level into a numeric value.
Definition: logging.c:146
int log_parse_category(const char *category)
parse a human-readable log category into numeric form
Definition: logging.c:161
const char * name
Definition: logging.h:98
VTY logging.
Definition: logging.h:147
void log_set_print_timestamp(struct log_target *target, int)
Enable or disable printing of timestamps while logging.
Definition: logging.c:470
enum log_target_type type
the type of this log taget
Definition: logging.h:180
uint8_t enabled
Definition: logging.h:102
syslog based logging
Definition: logging.h:148
const char * log_level_str(unsigned int lvl)
convert a numeric log level into human-readable string
Definition: logging.c:152
log_target_type
Type of logging target.
Definition: logging.h:146
void log_target_destroy(struct log_target *target)
Unregister, close and delete a log target.
Definition: logging.c:642
void log_set_use_color(struct log_target *target, int)
Enable or disable the use of colored output.
Definition: logging.c:461
#define LOG_MAX_FILTERS
Maximum number of logging filters.
Definition: logging.h:17
unsigned int print_category
should log messages be prefixed with a category name?
Definition: logging.h:175
void log_add_target(struct log_target *target)
Register a new log target with the logging core.
Definition: logging.c:402
int log_filter(const struct log_context *ctx, struct log_target *target)
Log filter function.
Definition: logging.h:113
osmo_strrb-backed logging
Definition: logging.h:151
text file logging
Definition: logging.h:149
void log_del_target(struct log_target *target)
Unregister a log target from the logging core.
Definition: logging.c:410
struct log_target * log_target_create_file(const char *fname)
Create a new file-based log target.
Definition: logging.c:600
stderr logging
Definition: logging.h:150
unsigned int print_filename
should log messages be prefixed with a filename?
Definition: logging.h:173
Definition: linuxlist.h:42
const char * color
Definition: logging.h:99
void log_set_print_filename(struct log_target *target, int)
Enable or disable printing of the filename while logging.
Definition: logging.c:492
const char * log_vty_command_string(const struct log_info *info)
Generates the logging command string for VTY.
Definition: logging.c:700
int log_set_context(uint8_t ctx, void *value)
Set the logging context.
Definition: logging.c:431
void log_set_print_category(struct log_target *target, int)
Enable or disable printing of the category name.
Definition: logging.c:503
struct log_category * categories
logging categories
Definition: logging.h:164
uint8_t loglevel
global log level
Definition: logging.h:167
struct log_target * log_target_create_stderr(void)
Create the STDERR log target.
Definition: logging.c:577
void log_parse_category_mask(struct log_target *target, const char *mask)
parse the log category mask
Definition: logging.c:182
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:523
int log_check_level(int subsys, unsigned int level)
Check whether a log entry will be generated.
Definition: logging.c:884
void int log_init(const struct log_info *inf, void *talloc_ctx)
Initialize the Osmocom logging core.
Definition: logging.c:839
const char * log_vty_command_description(const struct log_info *info)
Generates the logging command description for VTY.
Definition: logging.c:777
Logging configuration, passed to log_init.
Definition: logging.h:128
unsigned int print_timestamp
should log messages be prefixed with a timestamp?
Definition: logging.h:171
unsigned int num_cat_user
total number of user categories (not library)
Definition: logging.h:137
Log context information, passed to filter.
Definition: logging.h:106
void(* output)(struct log_target *target, unsigned int level, const char *string)
call-back function to be called when the logging framework wants to log somethnig.
Definition: logging.h:208
struct log_target * log_target_create(void)
Create a new log target skeleton.
Definition: logging.c:540
const struct log_info_cat * cat
per-category information
Definition: logging.h:133
unsigned int use_color
should color be used when printing log messages?
Definition: logging.h:169
struct log_target * log_target_find(int type, const char *fname)
Find a registered log target.
Definition: logging.c:625
unsigned int print_ext_timestamp
should log messages be prefixed with an extended timestamp?
Definition: logging.h:177
int log_target_file_reopen(struct log_target *tgt)
close and re-open a log file (for log file rotation)
Definition: logging.c:664
structure representing a logging target
Definition: logging.h:155
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:356
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:512
void log_reset_context(void)
Reset (clear) the logging context.
Definition: logging.c:416
#define LOG_MAX_CTX
Maximum number of logging contexts.
Definition: logging.h:15
uint8_t loglevel
Definition: logging.h:101
unsigned int num_cat
total number of categories
Definition: logging.h:135
void * filter_data[LOG_MAX_FILTERS+1]
Internal data for filtering.
Definition: logging.h:161
int log_targets_reopen(void)
close and re-open a log file (for log file rotation)
Definition: logging.c:678
void log_set_print_extended_timestamp(struct log_target *target, int)
Enable or disable printing of extended timestamps while logging.
Definition: logging.c:483
const char * description
Definition: logging.h:100
struct llist_head entry
linked list
Definition: logging.h:156