Print this page
OS-1840 fmdump shall emit JSON
Reviewed by: Robert Mustacchi <rm@joyent.com>

@@ -18,10 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  */
 
 /*
  * Rendering functions for nvlist_prt that are of use to all types
  * of log.

@@ -69,6 +70,22 @@
         nvlist_prtctl_dofmt(pctl, NVLIST_FMT_MEMBER_NAME, name);
         (void) fprintf(fp, "%s", fmristr);
         topo_hdl_strfree(thp, fmristr);
 
         return (1);
+}
+
+/*
+ * Thin wrapper around libnvpair's inbuilt JSON routine.  Simply dumps the
+ * entire log record nvlist without any reformatting.
+ */
+
+/*ARGSUSED*/
+int
+fmdump_print_json(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
+{
+        if (nvlist_print_json(fp, rp->rec_nvl) == 0 || fprintf(fp, "\n") < 0 ||
+            fflush(fp) != 0)
+                return (-1);
+
+        return (0);
 }