You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/07/05 22:29:43 UTC

[GitHub] ccollins476ad closed pull request #1248: sys/log/modlog: Empty functions when stub log impl

ccollins476ad closed pull request #1248: sys/log/modlog: Empty functions when stub log impl
URL: https://github.com/apache/mynewt-core/pull/1248
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sys/log/full/syscfg.yml b/sys/log/full/syscfg.yml
index 7912f70531..04a0065e5e 100644
--- a/sys/log/full/syscfg.yml
+++ b/sys/log/full/syscfg.yml
@@ -18,6 +18,12 @@
 #
 
 syscfg.defs:
+    LOG_FULL:
+        description: >
+            Indicates that the full logging facility (not the stub) is present.
+            This setting should not be overridden.
+        value: 1
+
     LOG_VERSION:
         description: 'Log entry header version used.'
         value: 2
diff --git a/sys/log/modlog/include/modlog/modlog.h b/sys/log/modlog/include/modlog/modlog.h
index 8e1a6f0f1c..4345b62eb4 100644
--- a/sys/log/modlog/include/modlog/modlog.h
+++ b/sys/log/modlog/include/modlog/modlog.h
@@ -84,6 +84,9 @@ struct modlog_desc {
  */
 typedef int modlog_foreach_fn(const struct modlog_desc *desc, void *arg);
 
+/* Only enable modlog if logging is also enabled. */
+#if MYNEWT_VAL(LOG_FULL) || defined(__DOXYGEN__)
+
 /**
  * @brief Retrieves the modlog mapping with the specified handle.
  *
@@ -200,6 +203,58 @@ int modlog_foreach(modlog_foreach_fn *fn, void *arg);
  */
 void modlog_printf(uint16_t module, uint16_t level, const char *msg, ...);
 
+#else /* LOG_FULL */
+
+static inline int
+modlog_get(uint8_t handle, struct modlog_desc *out_desc)
+{
+    return SYS_ENOTSUP;
+}
+
+static inline int
+modlog_register(uint8_t module, struct log *log, uint8_t min_level,
+                uint8_t *out_handle)
+{
+    return 0;
+}
+
+static inline int
+modlog_delete(uint8_t handle)
+{
+    return SYS_ENOTSUP;
+}
+
+static inline void
+modlog_clear(void)
+{ }
+
+static inline int
+modlog_append(uint8_t module, uint8_t level, uint8_t etype, void *data,
+              uint16_t len)
+{
+    return 0;
+}
+
+static inline int
+modlog_append_mbuf(uint8_t module, uint8_t level, uint8_t etype,
+                   struct os_mbuf *om)
+{
+    os_mbuf_free_chain(om);
+    return 0;
+}
+
+static inline int
+modlog_foreach(modlog_foreach_fn *fn, void *arg)
+{
+    return SYS_ENOTSUP;
+}
+
+static inline void
+modlog_printf(uint8_t module, uint8_t level, const char *msg, ...)
+{ }
+
+#endif
+
 #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_DEBUG || defined __DOXYGEN__
 /**
  * @brief Writes a formatted debug text entry to the specified log module.
diff --git a/sys/log/modlog/src/modlog.c b/sys/log/modlog/src/modlog.c
index fc81d1ce6f..3264b07ba8 100644
--- a/sys/log/modlog/src/modlog.c
+++ b/sys/log/modlog/src/modlog.c
@@ -23,6 +23,9 @@
 #include "log/log.h"
 #include "modlog/modlog.h"
 
+/* Only enable modlog if logging is also enabled. */
+#if MYNEWT_VAL(LOG_FULL)
+
 struct modlog_mapping {
     SLIST_ENTRY(modlog_mapping) next;
     struct modlog_desc desc;
@@ -493,3 +496,11 @@ modlog_init(void)
     SYSINIT_PANIC_ASSERT(rc == 0);
 #endif
 }
+
+#else /* LOG_FULL */
+
+void
+modlog_init(void)
+{ }
+
+#endif /* LOG_FULL */


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services