fs/nffs - add logging support.

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

Branch: refs/heads/develop
Commit: dd337a9f5397d4e3be5d6444db9abec741c3a2c2
Parents: a8f5e7f
Author: Christopher Collins <ccollins47...@gmail.com>
Authored: Wed Feb 24 11:17:43 2016 -0800
Committer: Christopher Collins <ccollins47...@gmail.com>
Committed: Wed Feb 24 11:17:43 2016 -0800

----------------------------------------------------------------------
 fs/nffs/pkg.yml           | 1 +
 fs/nffs/src/nffs.c        | 7 +++++++
 fs/nffs/src/nffs_priv.h   | 6 ++++++
 sys/log/include/log/log.h | 1 +
 4 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/dd337a9f/fs/nffs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/nffs/pkg.yml b/fs/nffs/pkg.yml
index ffec6f7..e6f7578 100644
--- a/fs/nffs/pkg.yml
+++ b/fs/nffs/pkg.yml
@@ -21,6 +21,7 @@ pkg.name: fs/nffs
 pkg.vers: 0.1
 pkg.identities: NFFS
 pkg.deps:
+    - sys/log
     - fs/fs
     - libs/os
     - libs/testutil

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/dd337a9f/fs/nffs/src/nffs.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs.c b/fs/nffs/src/nffs.c
index 0fd3755..ede074b 100644
--- a/fs/nffs/src/nffs.c
+++ b/fs/nffs/src/nffs.c
@@ -53,6 +53,9 @@ struct nffs_inode_entry *nffs_lost_found_dir;
 
 static struct os_mutex nffs_mutex;
 
+static struct log_handler nffs_log_console_handler;
+struct log nffs_log;
+
 static int nffs_open(const char *path, uint8_t access_flags,
   struct fs_file **out_file);
 static int nffs_close(struct fs_file *fs_file);
@@ -685,6 +688,10 @@ nffs_init(void)
         return FS_ENOMEM;
     }
 
+    log_init();
+    log_console_handler_init(&nffs_log_console_handler);
+    log_register("nffs", &nffs_log, &nffs_log_console_handler);
+
     rc = nffs_misc_reset();
     if (rc != 0) {
         return rc;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/dd337a9f/fs/nffs/src/nffs_priv.h
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs_priv.h b/fs/nffs/src/nffs_priv.h
index fe65053..119b5fa 100644
--- a/fs/nffs/src/nffs_priv.h
+++ b/fs/nffs/src/nffs_priv.h
@@ -21,6 +21,7 @@
 #define H_NFFS_PRIV_
 
 #include <inttypes.h>
+#include "log/log.h"
 #include "os/queue.h"
 #include "os/os_mempool.h"
 #include "nffs/nffs.h"
@@ -238,6 +239,8 @@ extern struct nffs_hash_list *nffs_hash;
 extern struct nffs_inode_entry *nffs_root_dir;
 extern struct nffs_inode_entry *nffs_lost_found_dir;
 
+extern struct log nffs_log;
+
 /* @area */
 int nffs_area_magic_is_set(const struct nffs_disk_area *disk_area);
 int nffs_area_is_scratch(const struct nffs_disk_area *disk_area);
@@ -427,4 +430,7 @@ int nffs_write_to_file(struct nffs_file *file, const void 
*data, int len);
 
 #define NFFS_FLASH_LOC_NONE  nffs_flash_loc(NFFS_AREA_ID_NONE, 0)
 
+#define NFFS_LOG(lvl, ...) \
+    LOG_ ## lvl(&nffs_log, LOG_MODULE_NFFS, __VA_ARGS__)
+
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/dd337a9f/sys/log/include/log/log.h
----------------------------------------------------------------------
diff --git a/sys/log/include/log/log.h b/sys/log/include/log/log.h
index c843638..68e7be2 100644
--- a/sys/log/include/log/log.h
+++ b/sys/log/include/log/log.h
@@ -70,6 +70,7 @@ struct log_entry_hdr {
 #define LOG_MODULE_NEWTMGR          (2)
 #define LOG_MODULE_NIMBLE_CTLR      (3)
 #define LOG_MODULE_NIMBLE_HOST      (4)
+#define LOG_MODULE_NFFS             (5)
 #define LOG_MODULE_PERUSER          (64)
 
 /* Compile in Log Debug by default */

Reply via email to