You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/04/08 20:14:08 UTC
[3/7] incubator-mynewt-core git commit: Adding log clear newtmgr
handler
Adding log clear newtmgr handler
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/806c5158
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/806c5158
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/806c5158
Branch: refs/heads/develop
Commit: 806c51588f0efbfd9a53e4c00d70aea8233d0e04
Parents: 480901f
Author: Vipul Rahane <vi...@runtime.io>
Authored: Thu Apr 7 13:52:14 2016 -0700
Committer: Vipul Rahane <vi...@runtime.io>
Committed: Thu Apr 7 13:52:14 2016 -0700
----------------------------------------------------------------------
sys/log/src/log_nmgr.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/806c5158/sys/log/src/log_nmgr.c
----------------------------------------------------------------------
diff --git a/sys/log/src/log_nmgr.c b/sys/log/src/log_nmgr.c
index efb9868..39bde0d 100644
--- a/sys/log/src/log_nmgr.c
+++ b/sys/log/src/log_nmgr.c
@@ -34,7 +34,7 @@
*/
static int log_nmgr_read(struct nmgr_jbuf *njb);
-
+static int log_nmgr_clear(struct nmgr_jbuf *njb);
static struct nmgr_group log_nmgr_group;
#define LOGS_NMGR_ID_READ (0)
@@ -45,7 +45,7 @@ static struct nmgr_group log_nmgr_group;
*/
static struct nmgr_handler log_nmgr_group_handlers[] = {
[LOGS_NMGR_ID_READ] = {log_nmgr_read, log_nmgr_read},
- [LOGS_NMGR_OP_CLEAR] = {NULL, NULL}, /* Stub */
+ [LOGS_NMGR_OP_CLEAR] = {log_nmgr_clear, log_nmgr_clear}
};
static int
@@ -136,6 +136,41 @@ err:
return (0);
}
+static int
+log_nmgr_clear(struct nmgr_jbuf *njb)
+{
+ struct log *log;
+ int rc;
+ struct json_encoder *encoder;
+
+ log = NULL;
+ while (1) {
+ log = log_list_get_next(log);
+ if (log == NULL) {
+ break;
+ }
+
+ if (log->l_log->log_type == LOG_TYPE_STREAM) {
+ continue;
+ }
+
+ rc = log_flush(log);
+ if (rc != 0) {
+ goto err;
+ }
+ }
+
+ encoder = (struct json_encoder *) &nmgr_task_jbuf.njb_enc;
+
+ json_encode_object_start(encoder);
+ json_encode_object_finish(encoder);
+
+ return 0;
+err:
+ nmgr_jbuf_setoerr(njb, rc);
+ return (rc);
+}
+
/**
* Register nmgr group handlers.
*/