logging: separate the '<000b>' subsys from filename logging
Add a separate flag and API to switch the category-in-hex output:
log_set_print_category_hex().
Add log_set_print_filename2() to modify only the print_filename flag. The old
log_set_print_filename() function still affects both flags. Explain the
rationale in the comment for log_set_print_filename().
There is no need to deprecate log_set_print_filename(); it might cause compiler
warnings and break strict builds unnecessarily.
Add VTY command 'logging print category-hex (0|1)'.
Since there is no VTY command to switch filename output, nothing needs to be
adjusted there (a command will be added in a subsequent patch).
Change-Id: Iba03a2b7915853c6dccaf6c393c31405320538b4
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index 1e809d0..1e79dab 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -220,6 +220,12 @@
LOG_TGT_TYPE_GSMTAP, /*!< GSMTAP network logging */
};
+/*! Whether/how to log the source filename (and line number). */
+enum log_filename_type {
+ LOG_FILENAME_NONE,
+ LOG_FILENAME_PATH,
+};
+
/*! structure representing a logging target */
struct log_target {
struct llist_head entry; /*!< linked list */
@@ -238,7 +244,7 @@
unsigned int use_color:1;
/*! should log messages be prefixed with a timestamp? */
unsigned int print_timestamp:1;
- /*! should log messages be prefixed with a filename? */
+ /*! DEPRECATED: use print_filename2 instead. */
unsigned int print_filename:1;
/*! should log messages be prefixed with a category name? */
unsigned int print_category:1;
@@ -301,6 +307,10 @@
/* Should the log level be printed? */
bool print_level;
+ /* Should we print the subsys in hex like '<000b>'? */
+ bool print_category_hex;
+ /* Should we print the source file and line, and in which way? */
+ enum log_filename_type print_filename2;
};
/* use the above macros */
@@ -322,7 +332,9 @@
void log_set_print_extended_timestamp(struct log_target *target, int);
void log_set_print_timestamp(struct log_target *target, int);
void log_set_print_filename(struct log_target *target, int);
+void log_set_print_filename2(struct log_target *target, enum log_filename_type lft);
void log_set_print_category(struct log_target *target, int);
+void log_set_print_category_hex(struct log_target *target, int);
void log_set_print_level(struct log_target *target, int);
void log_set_log_level(struct log_target *target, int log_level);
void log_parse_category_mask(struct log_target *target, const char* mask);