Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 260a90ebb -> 7f28def42


Change logging format to use 16-bit log index.

Change log struct (log_entry_hdr) from using an 8-bit to 16-bit index 
(ue_index) and reducing the log module number (ue_module) from 16-bit to 8-bit 
preserving the size of the structure. Also removed code which reset the index
every 1ms.

Added a version id in the global log_info structure so the log record format 
can be differentiated OTW or from non-volatile storage.

Partial checkin for MYNEWT-368 - remaining work to store record format in FCB.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2d7ed71e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2d7ed71e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2d7ed71e

Branch: refs/heads/develop
Commit: 2d7ed71e48fdbc65034e514238455cd7893de9cb
Parents: 260a90e
Author: Peter Snyder <g...@peterfs.com>
Authored: Thu Sep 1 17:20:18 2016 -0700
Committer: Peter Snyder <g...@peterfs.com>
Committed: Wed Sep 7 19:47:24 2016 -0700

----------------------------------------------------------------------
 sys/log/include/log/log.h | 7 +++++--
 sys/log/src/log.c         | 6 +-----
 2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d7ed71e/sys/log/include/log/log.h
----------------------------------------------------------------------
diff --git a/sys/log/include/log/log.h b/sys/log/include/log/log.h
index 1e974ff..2785bf6 100644
--- a/sys/log/include/log/log.h
+++ b/sys/log/include/log/log.h
@@ -28,7 +28,10 @@
 struct log_info {
     int64_t li_timestamp;
     uint8_t li_index;
+    uint8_t li_version;
 };
+#define LOG_VERSION_V2  2
+#define LOG_VERSION_V1  1
 
 extern struct log_info g_log_info;
 
@@ -65,8 +68,8 @@ struct log_handler {
 
 struct log_entry_hdr {
     int64_t ue_ts;
-    uint16_t ue_module;
-    uint8_t ue_index;
+    uint16_t ue_index;
+    uint8_t ue_module;
     uint8_t ue_level;
 }__attribute__((__packed__));
 #define LOG_ENTRY_HDR_SIZE (sizeof(struct log_entry_hdr))

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2d7ed71e/sys/log/src/log.c
----------------------------------------------------------------------
diff --git a/sys/log/src/log.c b/sys/log/src/log.c
index 6547d5a..23bb83a 100644
--- a/sys/log/src/log.c
+++ b/sys/log/src/log.c
@@ -113,6 +113,7 @@ log_append(struct log *log, uint16_t module, uint16_t 
level, void *data,
 
     ue = (struct log_entry_hdr *) data;
 
+    /* Could check for li_index wraparound here */
     g_log_info.li_index++;
 
     /* Try to get UTC Time */
@@ -134,11 +135,6 @@ log_append(struct log *log, uint16_t module, uint16_t 
level, void *data,
         goto err;
     }
 
-    /* Resetting index every millisecond */
-    if (g_log_info.li_timestamp > 1000 + prev_ts) {
-        g_log_info.li_index = 0;
-    }
-
     return (0);
 err:
     return (rc);

Reply via email to