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/sections/cper-section-ampere.c b/sections/cper-section-ampere.c
index 34d0829..5755fa1 100644
--- a/sections/cper-section-ampere.c
+++ b/sections/cper-section-ampere.c
@@ -3,6 +3,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-ampere.h>
+#include <libcper/log.h>
//Converts the given processor-generic CPER section into JSON IR.
json_object *cper_section_ampere_to_ir(const UINT8 *section, UINT32 size)
diff --git a/sections/cper-section-arm.c b/sections/cper-section-arm.c
index cd06131..6961d16 100644
--- a/sections/cper-section-arm.c
+++ b/sections/cper-section-arm.c
@@ -12,6 +12,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-arm.h>
+#include <libcper/log.h>
//Private pre-definitions.
json_object *
@@ -123,7 +124,8 @@
(record->ErrInfoNum * sizeof(EFI_ARM_ERROR_INFORMATION_ENTRY))) {
json_object_put(error_info_array);
json_object_put(section_ir);
- printf("Invalid CPER file: Invalid processor error info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor error info num.\n");
return NULL;
}
for (int i = 0; i < record->ErrInfoNum; i++) {
@@ -147,7 +149,8 @@
sizeof(EFI_ARM_CONTEXT_INFORMATION_HEADER)) {
json_object_put(context_info_array);
json_object_put(section_ir);
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
return NULL;
}
EFI_ARM_CONTEXT_INFORMATION_HEADER *header =
@@ -161,7 +164,8 @@
if (processor_context == NULL) {
json_object_put(context_info_array);
json_object_put(section_ir);
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
return NULL;
}
json_object_array_add(context_info_array, processor_context);
@@ -177,7 +181,8 @@
if (remaining_size < input_size) {
json_object_put(vendor_specific);
json_object_put(section_ir);
- printf("Invalid CPER file: Invalid vendor-specific info length.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid vendor-specific info length.\n");
return NULL;
}
int32_t encoded_len = 0;
@@ -186,7 +191,8 @@
if (encoded == NULL) {
json_object_put(vendor_specific);
json_object_put(section_ir);
- printf("base64 encode of vendorSpecificInfo failed\n");
+ cper_print_log(
+ "base64 encode of vendorSpecificInfo failed\n");
return NULL;
}
json_object_object_add(vendor_specific, "data",
@@ -197,7 +203,8 @@
json_object_object_add(section_ir, "vendorSpecificInfo",
vendor_specific);
} else {
- printf("vendorSpecificInfo is marked valid but not present in binary\n");
+ cper_print_log(
+ "vendorSpecificInfo is marked valid but not present in binary\n");
}
}
@@ -497,7 +504,8 @@
const UINT8 **cur_pos, UINT32 *remaining_size)
{
if (header->RegisterArraySize > *remaining_size) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
return NULL;
}
@@ -526,12 +534,14 @@
switch (header->RegisterContextType) {
case EFI_ARM_CONTEXT_TYPE_AARCH32_GPR:
if (*remaining_size < sizeof(EFI_ARM_V8_AARCH32_GPR)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_V8_AARCH32_GPR)) {
- printf("Invalid CPER file: Not enough bytes for aarch32 gpr\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch32 gpr\n");
goto fail;
}
register_array = uniform_struct_to_ir(
@@ -542,12 +552,14 @@
case EFI_ARM_CONTEXT_TYPE_AARCH32_EL1:
if (*remaining_size <
sizeof(EFI_ARM_AARCH32_EL1_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_AARCH32_EL1_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Not enough bytes for aarch32 el1\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch32 el1\n");
goto fail;
}
register_array = uniform_struct_to_ir(
@@ -559,12 +571,14 @@
case EFI_ARM_CONTEXT_TYPE_AARCH32_EL2:
if (*remaining_size <
sizeof(EFI_ARM_AARCH32_EL2_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_AARCH32_EL2_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Not enough bytes for aarch32 el2\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch32 el2\n");
goto fail;
}
register_array = uniform_struct_to_ir(
@@ -578,12 +592,14 @@
if (*remaining_size <
sizeof(EFI_ARM_AARCH32_SECURE_CONTEXT_REGISTERS)) {
json_object_put(context_ir);
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
return NULL;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_AARCH32_SECURE_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Not enough bytes for aarch32 secure\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch32 secure\n");
goto fail;
}
register_array = uniform_struct_to_ir(
@@ -594,12 +610,14 @@
break;
case EFI_ARM_CONTEXT_TYPE_AARCH64_GPR:
if (*remaining_size < sizeof(EFI_ARM_V8_AARCH64_GPR)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_V8_AARCH64_GPR)) {
- printf("Invalid CPER file: Not enough bytes for aarch64 gpr\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch64 gpr\n");
goto fail;
}
register_array = uniform_struct64_to_ir(
@@ -610,12 +628,14 @@
case EFI_ARM_CONTEXT_TYPE_AARCH64_EL1:
if (*remaining_size <
sizeof(EFI_ARM_AARCH64_EL1_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_AARCH64_EL1_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Not enough bytes for aarch64 el1\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch64 el1\n");
goto fail;
}
register_array = uniform_struct64_to_ir(
@@ -627,12 +647,14 @@
case EFI_ARM_CONTEXT_TYPE_AARCH64_EL2:
if (*remaining_size <
sizeof(EFI_ARM_AARCH64_EL2_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_AARCH64_EL2_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Not enough bytes for aarch64 el2\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch64 el2\n");
goto fail;
}
register_array = uniform_struct64_to_ir(
@@ -644,12 +666,14 @@
case EFI_ARM_CONTEXT_TYPE_AARCH64_EL3:
if (*remaining_size <
sizeof(EFI_ARM_AARCH64_EL3_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_AARCH64_EL3_CONTEXT_REGISTERS)) {
- printf("Invalid CPER file: Not enough bytes for aarch64 el3\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for aarch64 el3\n");
goto fail;
}
register_array = uniform_struct64_to_ir(
@@ -660,12 +684,14 @@
break;
case EFI_ARM_CONTEXT_TYPE_MISC:
if (*remaining_size < sizeof(EFI_ARM_MISC_CONTEXT_REGISTER)) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
if (header->RegisterArraySize <
sizeof(EFI_ARM_MISC_CONTEXT_REGISTER)) {
- printf("Invalid CPER file: Not enough bytes for misc\n");
+ cper_print_log(
+ "Invalid CPER file: Not enough bytes for misc\n");
goto fail;
}
register_array = cper_arm_misc_register_array_to_ir(
@@ -673,7 +699,8 @@
break;
default:
if (*remaining_size < header->RegisterArraySize) {
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
goto fail;
}
//Unknown register array type, add as base64 data instead.
@@ -1274,7 +1301,7 @@
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log("Failed to allocate decode output buffer. \n");
} else {
//Flush out to stream.
fwrite(&decoded, decoded_len, 1, out);
diff --git a/sections/cper-section-ccix-per.c b/sections/cper-section-ccix-per.c
index d68f422..a8a5310 100644
--- a/sections/cper-section-ccix-per.c
+++ b/sections/cper-section-ccix-per.c
@@ -11,6 +11,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-ccix-per.h>
+#include <libcper/log.h>
//Converts a single CCIX PER log CPER section into JSON IR.
json_object *cper_section_ccix_per_to_ir(const UINT8 *section, UINT32 size)
@@ -58,7 +59,8 @@
remaining_length,
&encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate encode output buffer. \n");
} else {
json_object_object_add(
section_ir, "ccixPERLog",
@@ -120,7 +122,8 @@
json_object_get_string(encoded),
json_object_get_string_len(encoded), &decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
fwrite(decoded, decoded_len, 1, out);
fflush(out);
diff --git a/sections/cper-section-cxl-component.c b/sections/cper-section-cxl-component.c
index cae152b..c4e8169 100644
--- a/sections/cper-section-cxl-component.c
+++ b/sections/cper-section-cxl-component.c
@@ -10,6 +10,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-cxl-component.h>
+#include <libcper/log.h>
//Converts a single CXL component error CPER section into JSON IR.
json_object *cper_section_cxl_component_to_ir(const UINT8 *section, UINT32 size)
@@ -82,7 +83,8 @@
char *encoded = base64_encode(cur_pos, remaining_len,
&encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate encode output buffer. \n");
json_object_put(section_ir);
return NULL;
}
@@ -166,7 +168,8 @@
json_object_get_string_len(encoded), &decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
fwrite(decoded, decoded_len, 1, out);
fflush(out);
diff --git a/sections/cper-section-cxl-protocol.c b/sections/cper-section-cxl-protocol.c
index 1a9b33b..ebf3648 100644
--- a/sections/cper-section-cxl-protocol.c
+++ b/sections/cper-section-cxl-protocol.c
@@ -10,6 +10,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-cxl-protocol.h>
+#include <libcper/log.h>
//Converts a single CXL protocol error CPER section into JSON IR.
json_object *cper_section_cxl_protocol_to_ir(const UINT8 *section, UINT32 size)
@@ -135,7 +136,8 @@
(UINT8 *)cxl_protocol_error->CapabilityStructure.PcieCap,
60, &encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate encode output buffer. \n");
json_object_put(section_ir);
return NULL;
@@ -190,7 +192,8 @@
&encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate encode output buffer. \n");
json_object_put(section_ir);
return NULL;
}
@@ -295,7 +298,8 @@
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
memcpy(section_cper->CapabilityStructure.PcieCap,
decoded, decoded_len);
@@ -338,7 +342,8 @@
json_object_get_string_len(encodedsrc),
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
fwrite(decoded, decoded_len, 1, out);
fflush(out);
@@ -353,7 +358,8 @@
json_object_get_string_len(encodederr),
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
fwrite(decoded, decoded_len, 1, out);
fflush(out);
diff --git a/sections/cper-section-dmar-generic.c b/sections/cper-section-dmar-generic.c
index e745d2b..d75647e 100644
--- a/sections/cper-section-dmar-generic.c
+++ b/sections/cper-section-dmar-generic.c
@@ -9,6 +9,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-dmar-generic.h>
+#include <libcper/log.h>
//Converts a single generic DMAr CPER section into JSON IR.
json_object *cper_section_dmar_generic_to_ir(const UINT8 *section, UINT32 size)
diff --git a/sections/cper-section-dmar-iommu.c b/sections/cper-section-dmar-iommu.c
index c411cf2..df22ce0 100644
--- a/sections/cper-section-dmar-iommu.c
+++ b/sections/cper-section-dmar-iommu.c
@@ -11,6 +11,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-dmar-iommu.h>
+#include <libcper/log.h>
//Converts a single IOMMU specific DMAr CPER section into JSON IR.
json_object *cper_section_dmar_iommu_to_ir(const UINT8 *section, UINT32 size)
@@ -40,7 +41,7 @@
char *encoded = base64_encode((UINT8 *)iommu_error->EventLogEntry, 16,
&encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log("Failed to allocate encode output buffer. \n");
return NULL;
}
@@ -55,7 +56,7 @@
encoded = base64_encode((UINT8 *)iommu_error->DeviceTableEntry, 32,
&encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log("Failed to allocate encode output buffer. \n");
return NULL;
}
json_object_object_add(section_ir, "deviceTableEntry",
@@ -103,7 +104,7 @@
json_object_get_string_len(encoded),
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log("Failed to allocate decode output buffer. \n");
} else {
memcpy(section_cper->EventLogEntry, decoded, decoded_len);
free(decoded);
@@ -116,7 +117,7 @@
json_object_get_string_len(encoded),
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log("Failed to allocate decode output buffer. \n");
} else {
memcpy(section_cper->DeviceTableEntry, decoded, decoded_len);
free(decoded);
diff --git a/sections/cper-section-dmar-vtd.c b/sections/cper-section-dmar-vtd.c
index ad86293..fcbce18 100644
--- a/sections/cper-section-dmar-vtd.c
+++ b/sections/cper-section-dmar-vtd.c
@@ -11,6 +11,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-dmar-vtd.h>
+#include <libcper/log.h>
//Converts a single VT-d specific DMAr CPER section into JSON IR.
json_object *cper_section_dmar_vtd_to_ir(const UINT8 *section, UINT32 size)
@@ -100,7 +101,7 @@
encoded = base64_encode((UINT8 *)vtd_error->ContextEntry, 16,
&encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log("Failed to allocate encode output buffer. \n");
} else {
json_object_object_add(section_ir, "contextEntry",
json_object_new_string_len(encoded,
@@ -188,7 +189,7 @@
json_object_get_string_len(encoded),
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log("Failed to allocate decode output buffer. \n");
} else {
memcpy(section_cper->RootEntry, decoded, decoded_len);
free(decoded);
@@ -202,7 +203,7 @@
json_object_get_string_len(encoded),
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log("Failed to allocate decode output buffer. \n");
} else {
memcpy(section_cper->ContextEntry, decoded, decoded_len);
diff --git a/sections/cper-section-firmware.c b/sections/cper-section-firmware.c
index 327d70b..b88d69e 100644
--- a/sections/cper-section-firmware.c
+++ b/sections/cper-section-firmware.c
@@ -9,6 +9,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-firmware.h>
+#include <libcper/log.h>
//Converts a single firmware CPER section into JSON IR.
json_object *cper_section_firmware_to_ir(const UINT8 *section, UINT32 size)
diff --git a/sections/cper-section-generic.c b/sections/cper-section-generic.c
index 0937de4..8117419 100644
--- a/sections/cper-section-generic.c
+++ b/sections/cper-section-generic.c
@@ -11,6 +11,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-generic.h>
+#include <libcper/log.h>
//Converts the given processor-generic CPER section into JSON IR.
json_object *cper_section_generic_to_ir(const UINT8 *section, UINT32 size)
diff --git a/sections/cper-section-ia32x64.c b/sections/cper-section-ia32x64.c
index fe3acca..8f84c11 100644
--- a/sections/cper-section-ia32x64.c
+++ b/sections/cper-section-ia32x64.c
@@ -11,6 +11,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-ia32x64.h>
+#include <libcper/log.h>
//Private pre-definitions.
json_object *cper_ia32x64_processor_error_info_to_ir(
@@ -99,7 +100,8 @@
sizeof(EFI_IA32_X64_PROCESS_ERROR_INFO))) {
json_object_put(error_info_array);
json_object_put(record_ir);
- printf("Invalid CPER file: Invalid processor error info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor error info num.\n");
return NULL;
}
@@ -119,7 +121,8 @@
if (remaining_size < (processor_context_info_num *
sizeof(EFI_IA32_X64_PROCESSOR_CONTEXT_INFO))) {
json_object_put(record_ir);
- printf("Invalid CPER file: Invalid processor context info num.\n");
+ cper_print_log(
+ "Invalid CPER file: Invalid processor context info num.\n");
return NULL;
}
EFI_IA32_X64_PROCESSOR_CONTEXT_INFO *current_context_info =
@@ -210,7 +213,8 @@
break;
default:
//Unknown check information.
- printf("WARN: Invalid/unknown check information GUID found in IA32/x64 CPER section. Ignoring.\n");
+ cper_print_log(
+ "WARN: Invalid/unknown check information GUID found in IA32/x64 CPER section. Ignoring.\n");
break;
}
@@ -522,7 +526,8 @@
context_info->ArraySize,
&encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate encode output buffer. \n");
} else {
register_array = json_object_new_object();
json_object_object_add(register_array, "data",
@@ -802,7 +807,8 @@
break;
default:
//Unknown check information.
- printf("WARN: Invalid/unknown check information GUID found in IA32/x64 CPER section. Ignoring.\n");
+ cper_print_log(
+ "WARN: Invalid/unknown check information GUID found in IA32/x64 CPER section. Ignoring.\n");
break;
}
add_to_valid_bitfield(&ui64Type, 0);
@@ -1028,7 +1034,8 @@
int j_size = json_object_get_string_len(encoded);
UINT8 *decoded = base64_decode(j_string, j_size, &decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
fwrite(decoded, decoded_len, 1, out);
fflush(out);
diff --git a/sections/cper-section-ipf.c b/sections/cper-section-ipf.c
index 2cf6f13..fb9243e 100644
--- a/sections/cper-section-ipf.c
+++ b/sections/cper-section-ipf.c
@@ -9,6 +9,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-ipf.h>
+#include <libcper/log.h>
json_object *cper_ipf_mod_error_read_array(EFI_IPF_MOD_ERROR_INFO **cur_error,
int num_to_read);
diff --git a/sections/cper-section-memory.c b/sections/cper-section-memory.c
index b58bf82..347039a 100644
--- a/sections/cper-section-memory.c
+++ b/sections/cper-section-memory.c
@@ -9,6 +9,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-memory.h>
+#include <libcper/log.h>
//Converts a single memory error CPER section into JSON IR.
json_object *cper_section_platform_memory_to_ir(const UINT8 *section,
diff --git a/sections/cper-section-nvidia.c b/sections/cper-section-nvidia.c
index 874e616..ae14330 100644
--- a/sections/cper-section-nvidia.c
+++ b/sections/cper-section-nvidia.c
@@ -10,6 +10,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-nvidia.h>
+#include <libcper/log.h>
//Converts a single NVIDIA CPER section into JSON IR.
json_object *cper_section_nvidia_to_ir(const UINT8 *section, UINT32 size)
diff --git a/sections/cper-section-pci-bus.c b/sections/cper-section-pci-bus.c
index ac13187..60840e7 100644
--- a/sections/cper-section-pci-bus.c
+++ b/sections/cper-section-pci-bus.c
@@ -10,6 +10,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-pci-bus.h>
+#include <libcper/log.h>
//Converts a single PCI/PCI-X bus CPER section into JSON IR.
json_object *cper_section_pci_bus_to_ir(const UINT8 *section, UINT32 size)
diff --git a/sections/cper-section-pci-dev.c b/sections/cper-section-pci-dev.c
index 9f89494..359e56e 100644
--- a/sections/cper-section-pci-dev.c
+++ b/sections/cper-section-pci-dev.c
@@ -9,6 +9,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-pci-dev.h>
+#include <libcper/log.h>
//Converts a single PCI/PCI-X device CPER section into JSON IR.
json_object *cper_section_pci_dev_to_ir(const UINT8 *section, UINT32 size)
diff --git a/sections/cper-section-pcie.c b/sections/cper-section-pcie.c
index e616728..ee8a1d9 100644
--- a/sections/cper-section-pcie.c
+++ b/sections/cper-section-pcie.c
@@ -11,6 +11,7 @@
#include <libcper/Cper.h>
#include <libcper/cper-utils.h>
#include <libcper/sections/cper-section-pcie.h>
+#include <libcper/log.h>
struct aer_info_registers {
UINT32 pcie_capability_header;
@@ -150,7 +151,8 @@
base64_encode((UINT8 *)pcie_error->Capability.PcieCap,
60, &encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate encode output buffer. \n");
} else {
json_object *capability = json_object_new_object();
json_object_object_add(capability, "data",
@@ -172,7 +174,8 @@
encoded = base64_encode((UINT8 *)pcie_error->AerInfo.PcieAer,
96, &encoded_len);
if (encoded == NULL) {
- printf("Failed to allocate encode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate encode output buffer. \n");
} else {
json_object_object_add(aer_capability_ir, "data",
json_object_new_string_len(
@@ -341,7 +344,8 @@
json_object_get_string(encoded),
json_object_get_string_len(encoded), &decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
memcpy(section_cper->Capability.PcieCap, decoded,
decoded_len);
@@ -363,7 +367,8 @@
&decoded_len);
if (decoded == NULL) {
- printf("Failed to allocate decode output buffer. \n");
+ cper_print_log(
+ "Failed to allocate decode output buffer. \n");
} else {
memcpy(section_cper->AerInfo.PcieAer, decoded,
decoded_len);