Implement common logging function

When used as a library, it's desirable to be able to suppress logging,
or pipe logging through a different path.  This commit changes behavior
such that logging is disabled by default, and introduces 2 new methods,
cper_set_log_stdio and cper_set_log_custom.

These allow library integrators to specify their logging mode.  In
practice, this also allows fuzzing to run faster by not printing errors
to the log.

Change-Id: I941476627bc9b8261ba5f6c0b2b2338fdf931dd2
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/cper-utils.c b/cper-utils.c
index ffc8ded..ae71dc4 100644
--- a/cper-utils.c
+++ b/cper-utils.c
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <libcper/Cper.h>
 #include <libcper/cper-utils.h>
+#include <libcper/log.h>
 
 //The available severity types for CPER.
 const char *CPER_SEVERITY_TYPES[4] = { "Recoverable", "Fatal", "Corrected",
@@ -217,8 +218,9 @@
 		val->value.ui64 |= (0x01 << vbit_idx);
 		break;
 	default:
-		printf("IR to CPER: Unknown validation bits size passed, Enum IntType=%d",
-		       val->size);
+		cper_print_log(
+			"IR to CPER: Unknown validation bits size passed, Enum IntType=%d",
+			val->size);
 	}
 }
 
@@ -258,8 +260,9 @@
 		return (vbit_mask & val->value.ui64);
 
 	default:
-		printf("CPER to IR:Unknown validation bits size passed. Enum IntType: %d",
-		       val->size);
+		cper_print_log(
+			"CPER to IR:Unknown validation bits size passed. Enum IntType: %d",
+			val->size);
 	}
 	return 0;
 }
@@ -268,23 +271,24 @@
 {
 	switch (val->size) {
 	case UINT_8T:
-		printf("Validation bits: %x\n", val->value.ui8);
+		cper_print_log("Validation bits: %x\n", val->value.ui8);
 		break;
 	case UINT_16T:
-		printf("Validation bits: %x\n", val->value.ui16);
+		cper_print_log("Validation bits: %x\n", val->value.ui16);
 		break;
 
 	case UINT_32T:
-		printf("Validation bits: %x\n", val->value.ui32);
+		cper_print_log("Validation bits: %x\n", val->value.ui32);
 		break;
 
 	case UINT_64T:
-		printf("Validation bits: %llx\n", val->value.ui64);
+		cper_print_log("Validation bits: %llx\n", val->value.ui64);
 		break;
 
 	default:
-		printf("CPER to IR:Unknown validation bits size passed. Enum IntType: %d",
-		       val->size);
+		cper_print_log(
+			"CPER to IR:Unknown validation bits size passed. Enum IntType: %d",
+			val->size);
 	}
 }
 
@@ -355,7 +359,7 @@
 		century, year, month, day, hours, minutes, seconds);
 
 	if (written < 0 || written >= out_len) {
-		printf("Timestamp buffer of insufficient size\n");
+		cper_print_log("Timestamp buffer of insufficient size\n");
 		return -1;
 	}
 	return 0;