Remove old uses of cout/cerr

Most of this code was written before bmcweb had a logger, and
therefore used cout/cerr.

This commit greps the codebase and finds all places where we still
use cout/cerr, and moves them to logging.

Tested: Inspection only.  No functional changes.

Change-Id: I5ce1883c9941e80203ec29decb3a0206fd118506
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/include/ossl_random.hpp b/include/ossl_random.hpp
index 2cbec84..b392410 100644
--- a/include/ossl_random.hpp
+++ b/include/ossl_random.hpp
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "logging.hpp"
+
 #include <openssl/rand.h>
 
 #include <iostream>
@@ -17,7 +19,7 @@
         int rc = RAND_bytes(&index, sizeof(index));
         if (rc != opensslSuccess)
         {
-            std::cerr << "Cannot get random number\n";
+            BMCWEB_LOG_ERROR("Cannot get random number");
             err = true;
         }
 
diff --git a/include/ssl_key_handler.hpp b/include/ssl_key_handler.hpp
index 5ce7cc7..d12fcab 100644
--- a/include/ssl_key_handler.hpp
+++ b/include/ssl_key_handler.hpp
@@ -106,7 +106,7 @@
     bool privateKeyValid = false;
     bool certValid = false;
 
-    std::cout << "Checking certs in file " << filepath << "\n";
+    BMCWEB_LOG_INFO("Checking certs in file {}", filepath);
 
     FILE* file = fopen(filepath.c_str(), "r");
     if (file != nullptr)
@@ -118,15 +118,15 @@
             RSA* rsa = EVP_PKEY_get1_RSA(pkey);
             if (rsa != nullptr)
             {
-                std::cout << "Found an RSA key\n";
+                BMCWEB_LOG_INFO("Found an RSA key");
                 if (RSA_check_key(rsa) == 1)
                 {
                     privateKeyValid = true;
                 }
                 else
                 {
-                    std::cerr << "Key not valid error number "
-                              << ERR_get_error() << "\n";
+                    BMCWEB_LOG_ERROR("Key not valid error number {}",
+                                     ERR_get_error());
                 }
                 RSA_free(rsa);
             }
@@ -135,15 +135,15 @@
                 EC_KEY* ec = EVP_PKEY_get1_EC_KEY(pkey);
                 if (ec != nullptr)
                 {
-                    std::cout << "Found an EC key\n";
+                    BMCWEB_LOG_INFO("Found an EC key");
                     if (EC_KEY_check_key(ec) == 1)
                     {
                         privateKeyValid = true;
                     }
                     else
                     {
-                        std::cerr << "Key not valid error number "
-                                  << ERR_get_error() << "\n";
+                        BMCWEB_LOG_ERROR("Key not valid error number {}",
+                                         ERR_get_error());
                     }
                     EC_KEY_free(ec);
                 }
@@ -154,8 +154,8 @@
 
             if (pkeyCtx == nullptr)
             {
-                std::cerr << "Unable to allocate pkeyCtx " << ERR_get_error()
-                          << "\n";
+                BMCWEB_LOG_ERROR("Unable to allocate pkeyCtx {}",
+                                 ERR_get_error());
             }
             else if (EVP_PKEY_check(pkeyCtx) == 1)
             {
@@ -163,8 +163,8 @@
             }
             else
             {
-                std::cerr << "Key not valid error number " << ERR_get_error()
-                          << "\n";
+                BMCWEB_LOG_ERROR("Key not valid error number {}",
+                                 ERR_get_error());
             }
 #endif
 
@@ -179,8 +179,8 @@
                 X509* x509 = PEM_read_X509(file, nullptr, nullptr, nullptr);
                 if (x509 == nullptr)
                 {
-                    std::cout << "error getting x509 cert " << ERR_get_error()
-                              << "\n";
+                    BMCWEB_LOG_ERROR("error getting x509 cert {}",
+                                     ERR_get_error());
                 }
                 else
                 {
@@ -253,14 +253,14 @@
                                    const std::string& cn)
 {
     FILE* pFile = nullptr;
-    std::cout << "Generating new keys\n";
+    BMCWEB_LOG_INFO("Generating new keys");
     initOpenssl();
 
-    std::cerr << "Generating EC key\n";
+    BMCWEB_LOG_INFO("Generating EC key");
     EVP_PKEY* pPrivKey = createEcKey();
     if (pPrivKey != nullptr)
     {
-        std::cerr << "Generating x509 Certificate\n";
+        BMCWEB_LOG_INFO("Generating x509 Certificates");
         // Use this code to directly generate a certificate
         X509* x509 = X509_new();
         if (x509 != nullptr)
@@ -359,7 +359,7 @@
                 /* pKey owns myecc from now */
                 if (EC_KEY_check_key(myecc) <= 0)
                 {
-                    std::cerr << "EC_check_key failed.\n";
+                    BMCWEB_LOG_ERROR("EC_check_key failed.");
                 }
             }
         }
@@ -423,7 +423,7 @@
 
     if (!pemFileValid)
     {
-        std::cerr << "Error in verifying signature, regenerating\n";
+        BMCWEB_LOG_WARNING("Error in verifying signature, regenerating");
         generateSslCertificate(filepath, "testhost");
     }
 }