pespin has uploaded this change for review.

View Change

logging: Make struct log_context and struct log_target private

Change-Id: Iecbd07995ccb465a44be0debcc97458b2b240a0e
---
M TODO-RELEASE
M include/osmocom/core/logging.h
M include/osmocom/core/logging_internal.h
M src/core/logging.c
M src/core/logging_gsmtap.c
M src/core/logging_syslog.c
M src/core/loggingrb.c
7 files changed, 115 insertions(+), 111 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/91/41891/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index b7d1585..d42d650 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -11,3 +11,4 @@
core added gsmtap_source_set_nonblock(), gsmtap_source_using_wq()
core added osmo_iofd_set_name_f()
core added log_{get,set}_filter(_data)(), log_get_context()
+core deleted struct log_context, struct log_target members made private
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index 286f646..0c85a6e 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -9,7 +9,6 @@
#include <stdarg.h>
#include <stdbool.h>
#include <osmocom/core/defs.h>
-#include <osmocom/core/linuxlist.h>

extern struct log_info *osmo_log_info;

@@ -223,11 +222,6 @@
/*! Maximum number of logging filters */
#define LOG_MAX_FILTERS _LOG_FLT_COUNT

-/*! Log context information, passed to filter */
-struct log_context {
- void *ctx[LOG_MAX_CTX+1] OSMO_DEPRECATED_OUTSIDE("Accessing struct log_context members directly is deprecated");
-};
-
/*! Compatibility with older libosmocore versions */
#define LOG_FILTER_ALL (1<<LOG_FLT_ALL)
/*! Compatibility with older libosmocore versions */
@@ -237,6 +231,10 @@
/*! Indexes to indicate the object currently acted upon.
* Array indexes for the global \a log_context array. */

+/*! Log context information, passed to filter */
+struct log_context;
+
+/*! structure representing a logging target */
struct log_target;

/*! Log filter function */
@@ -297,106 +295,6 @@
LOG_FILENAME_POS_LINE_END,
};

-/*! structure representing a logging target */
-#define OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE_LOG_TARGET \
- OSMO_DEPRECATED_OUTSIDE("Accessing struct log_target members directly is deprecated")
-struct log_target {
- struct llist_head entry; /*!< linked list */
-
- /*! Internal data for filtering */
- int filter_map OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE_LOG_TARGET;
- /*! Internal data for filtering */
- void *filter_data[LOG_MAX_FILTERS+1] OSMO_DEPRECATED_OUTSIDE_LIBOSMOCORE_LOG_TARGET;
-
- /*! logging categories */
- struct log_category *categories;
-
- /*! global log level */
- uint8_t loglevel;
- /*! should color be used when printing log messages? */
- unsigned int use_color:1;
- /*! should log messages be prefixed with a timestamp? */
- unsigned int print_timestamp:1;
- /*! should log messages be prefixed with the logger Thread ID? */
- unsigned int print_tid:1;
- /*! DEPRECATED: use print_filename2 instead. */
- unsigned int print_filename:1;
- /*! should log messages be prefixed with a category name? */
- unsigned int print_category:1;
- /*! should log messages be prefixed with an extended timestamp? */
- unsigned int print_ext_timestamp:1;
-
- /*! the type of this log taget */
- enum log_target_type type;
-
- union {
- struct {
- /* direct, blocking output via stdio */
- FILE *out;
- const char *fname;
- /* indirect output via write_queue and osmo_select_main() */
- struct osmo_wqueue *wqueue;
- } tgt_file;
-
- struct {
- int priority;
- int facility;
- } tgt_syslog;
-
- struct {
- void *vty;
- } tgt_vty;
-
- struct {
- void *rb;
- } tgt_rb;
-
- struct {
- struct gsmtap_inst *gsmtap_inst;
- const char *ident;
- const char *hostname;
- } tgt_gsmtap;
-
- struct {
- bool raw;
- } sd_journal;
- };
-
- /*! call-back function to be called when the logging framework
- * wants to log a fully formatted string
- * \param[in] target logging target
- * \param[in] level log level of currnet message
- * \param[in] string the string that is to be written to the log
- */
- void (*output)(struct log_target *target, unsigned int level,
- const char *string);
-
- /*! alternative call-back function to which the logging
- * framework passes the unfortmatted input arguments,
- * i.e. bypassing the internal string formatter
- * \param[in] target logging target
- * \param[in] subsys logging sub-system
- * \param[in] level logging level
- * \param[in] file soure code file name
- * \param[in] line source code file line number
- * \param[in] cont continuation of previous statement?
- * \param[in] format format string
- * \param[in] ap vararg list of printf arguments
- */
- 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);
-
- /* 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;
- /* Where on a log line to put the source file info. */
- enum log_filename_pos print_filename_pos;
-};
-
/* use the above macros */
void logp2(int subsys, unsigned int level, const char *file,
int line, int cont, const char *format, ...)
@@ -406,7 +304,6 @@
void log_fini(void);
int log_check_level(int subsys, unsigned int level);

-/* context management */
void log_reset_context(void);
int log_set_context(uint8_t ctx_nr, void *value);
void *log_get_context(const struct log_context *ctx, uint8_t ctx_nr);
diff --git a/include/osmocom/core/logging_internal.h b/include/osmocom/core/logging_internal.h
index 2e65660..6fc9b2a 100644
--- a/include/osmocom/core/logging_internal.h
+++ b/include/osmocom/core/logging_internal.h
@@ -4,7 +4,113 @@
* @{
* \file logging_internal.h */

+#include <stdint.h>
+
#include <osmocom/core/utils.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/logging.h>
+
+/*! Log context information, passed to filter */
+struct log_context {
+ void *ctx[LOG_MAX_CTX+1] OSMO_DEPRECATED_OUTSIDE("Accessing struct log_context members directly is deprecated");
+};
+
+struct log_target {
+ struct llist_head entry; /*!< linked list */
+
+ /*! Internal data for filtering */
+ int filter_map;
+ /*! Internal data for filtering */
+ void *filter_data[LOG_MAX_FILTERS+1];
+
+ /*! logging categories */
+ struct log_category *categories;
+
+ /*! global log level */
+ uint8_t loglevel;
+ /*! should color be used when printing log messages? */
+ unsigned int use_color:1;
+ /*! should log messages be prefixed with a timestamp? */
+ unsigned int print_timestamp:1;
+ /*! should log messages be prefixed with the logger Thread ID? */
+ unsigned int print_tid:1;
+ /*! DEPRECATED: use print_filename2 instead. */
+ unsigned int print_filename:1;
+ /*! should log messages be prefixed with a category name? */
+ unsigned int print_category:1;
+ /*! should log messages be prefixed with an extended timestamp? */
+ unsigned int print_ext_timestamp:1;
+
+ /*! the type of this log taget */
+ enum log_target_type type;
+
+ union {
+ struct {
+ /* direct, blocking output via stdio */
+ FILE *out;
+ const char *fname;
+ /* indirect output via write_queue and osmo_select_main() */
+ struct osmo_wqueue *wqueue;
+ } tgt_file;
+
+ struct {
+ int priority;
+ int facility;
+ } tgt_syslog;
+
+ struct {
+ void *vty;
+ } tgt_vty;
+
+ struct {
+ void *rb;
+ } tgt_rb;
+
+ struct {
+ struct gsmtap_inst *gsmtap_inst;
+ const char *ident;
+ const char *hostname;
+ } tgt_gsmtap;
+
+ struct {
+ bool raw;
+ } sd_journal;
+ };
+
+ /*! call-back function to be called when the logging framework
+ * wants to log a fully formatted string
+ * \param[in] target logging target
+ * \param[in] level log level of currnet message
+ * \param[in] string the string that is to be written to the log
+ */
+ void (*output)(struct log_target *target, unsigned int level,
+ const char *string);
+
+ /*! alternative call-back function to which the logging
+ * framework passes the unfortmatted input arguments,
+ * i.e. bypassing the internal string formatter
+ * \param[in] target logging target
+ * \param[in] subsys logging sub-system
+ * \param[in] level logging level
+ * \param[in] file soure code file name
+ * \param[in] line source code file line number
+ * \param[in] cont continuation of previous statement?
+ * \param[in] format format string
+ * \param[in] ap vararg list of printf arguments
+ */
+ 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);
+
+ /* 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;
+ /* Where on a log line to put the source file info. */
+ enum log_filename_pos print_filename_pos;
+};

extern void *tall_log_ctx;
extern struct log_info *osmo_log_info;
diff --git a/src/core/logging.c b/src/core/logging.c
index ac10d00..748dd8f 100644
--- a/src/core/logging.c
+++ b/src/core/logging.c
@@ -62,7 +62,7 @@

#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
-#include <osmocom/core/logging.h>
+#include <osmocom/core/logging_internal.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/thread.h>
#include <osmocom/core/select.h>
diff --git a/src/core/logging_gsmtap.c b/src/core/logging_gsmtap.c
index 062efd9..dfde937 100644
--- a/src/core/logging_gsmtap.c
+++ b/src/core/logging_gsmtap.c
@@ -44,7 +44,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/core/gsmtap_util.h>
-#include <osmocom/core/logging.h>
+#include <osmocom/core/logging_internal.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/core/thread.h>
diff --git a/src/core/logging_syslog.c b/src/core/logging_syslog.c
index eb84057..6659ac0 100644
--- a/src/core/logging_syslog.c
+++ b/src/core/logging_syslog.c
@@ -36,7 +36,7 @@

#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
-#include <osmocom/core/logging.h>
+#include <osmocom/core/logging_internal.h>

static int logp2syslog_level(unsigned int level)
{
diff --git a/src/core/loggingrb.c b/src/core/loggingrb.c
index 2bf7b66..f2f3e03 100644
--- a/src/core/loggingrb.c
+++ b/src/core/loggingrb.c
@@ -30,7 +30,7 @@
* \file loggingrb.c */

#include <osmocom/core/strrb.h>
-#include <osmocom/core/logging.h>
+#include <osmocom/core/logging_internal.h>
#include <osmocom/core/loggingrb.h>

static void _rb_output(struct log_target *target,

To view, visit change 41891. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iecbd07995ccb465a44be0debcc97458b2b240a0e
Gerrit-Change-Number: 41891
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>