Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/wolfprovider/wp_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
* WOLFPROV_LOG_PRINTF Define to Use printf instead of fprintf (to stderr)
* for logs. Not applicable if using WOLFPROV_USER_LOG
* or custom logging callback.
* WOLFPROV_LOG_FILE Define to specify a file path for debug output instead
* of stderr. This is typically set via --debug-log=FILE
* build script argument.
*
* COMPILE-TIME MACRO CONFIGURATIONS:
* Define these macros in this header to control logging at compile time:
Expand Down
10 changes: 10 additions & 0 deletions scripts/build-wolfprovider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ show_help() {
echo " --clean Run make clean in OpenSSL, wolfSSL, and wolfProvider"
echo " --distclean Remove source and install directories of OpenSSL, wolfSSL, and wolfProvider"
echo " --debug Builds OpenSSL, wolfSSL, and WolfProvider with debugging enabled. This is the same as setting WOLFPROV_DEBUG=1"
echo " --debug-log=FILE Force all wolfProvider debug output to specified log file instead of stderr/stdout (FILE = path to log file you want to use)"
echo " --debug-asn-template Enable debug information for asn within wolfSSL"
echo " --disable-err-trace No debug trace messages from library errors in wolfSSL"
echo " --openssl-ver=VER Which version of OpenSSL to clone"
Expand All @@ -33,6 +34,7 @@ show_help() {
echo " WOLFPROV_CLEAN If set to 1, run make clean in OpenSSL, wolfSSL, and wolfProvider"
echo " WOLFPROV_DISTCLEAN If set to 1, remove the source and install directories of OpenSSL, wolfSSL, and wolfProvider"
echo " WOLFPROV_DEBUG If set to 1, builds OpenSSL, wolfSSL, and wolfProvider with debug options enabled"
echo " WOLFPROV_LOG_FILE Path to log file for wolfProvider debug output (alternative to stderr)"
echo " WOLFPROV_QUICKTEST If set to 1, disables some tests in the test suite to increase test speed"
echo " WOLFPROV_DISABLE_ERR_TRACE If set to 1, wolfSSL will not be configured with --enable-debug-trace-errcodes=backtrace"
echo " WOLFPROV_LEAVE_SILENT If set to 1, suppress logging of return 0 in functions where return 0 is expected behavior sometimes."
Expand All @@ -57,6 +59,14 @@ for arg in "$@"; do
--debug)
WOLFPROV_DEBUG=1
;;
--debug-log=*)
IFS='=' read -r trash log_file <<< "$arg"
if [ -z "$log_file" ]; then
echo "No file path given for --debug-log"
args_wrong+="$arg, "
fi
WOLFPROV_LOG_FILE="$log_file"
;;
--debug-asn-template)
WOLFSSL_DEBUG_ASN_TEMPLATE=1
;;
Expand Down
2 changes: 2 additions & 0 deletions scripts/utils-openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ install_openssl() {
}

init_openssl() {
WOLFPROV_BUILD_DEBIAN=${WOLFPROV_BUILD_DEBIAN:-0}

if [ $WOLFPROV_BUILD_DEBIAN -eq 1 ]; then
install_openssl_deb
else
Expand Down
4 changes: 4 additions & 0 deletions scripts/utils-wolfprovider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ install_wolfprov() {
WOLFPROV_CONFIG_CFLAGS="${WOLFPROV_CONFIG_CFLAGS} -DWOLFPROV_LEAVE_SILENT_MODE"
fi

if [ -n "${WOLFPROV_LOG_FILE}" ]; then
WOLFPROV_CONFIG_CFLAGS="${WOLFPROV_CONFIG_CFLAGS} -DWOLFPROV_LOG_FILE=\\\"${WOLFPROV_LOG_FILE}\\\""
fi

./configure ${WOLFPROV_CONFIG_OPTS} CFLAGS="${WOLFPROV_CONFIG_CFLAGS}" >>$LOG_FILE 2>&1
RET=$?
if [ $RET != 0 ]; then
Expand Down
12 changes: 12 additions & 0 deletions src/wp_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ static void wolfprovider_log(const int logLevel, const int component,
WOLFPROV_USER_LOG(logMessage);
#elif defined(WOLFPROV_LOG_PRINTF)
printf("%s\n", logMessage);
#elif defined(WOLFPROV_LOG_FILE)
{
FILE* logFile = fopen(WOLFPROV_LOG_FILE, "a");
if (logFile != NULL) {
fprintf(logFile, "%s\n", logMessage);
fclose(logFile);
} else {
fprintf(stderr, "wolfProvider: Failed to open log file %s\n",
WOLFPROV_LOG_FILE);
fprintf(stderr, "%s\n", logMessage);
}
}
#else
fprintf(stderr, "%s\n", logMessage);
#endif
Expand Down
Loading