logging: switch to lg2
After switching to C++20, it is recommended to use `phosphor::lg2`
to format log, and the correct `CODE_LINE` and `CODE_FUNC` values
can be used in log tracking.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I4aabaafe997e13c10d655a83a9ef0071ad11126e
diff --git a/auth_algo.cpp b/auth_algo.cpp
index 4572831..40d277f 100644
--- a/auth_algo.cpp
+++ b/auth_algo.cpp
@@ -1,12 +1,12 @@
#include "auth_algo.hpp"
+#include <error.h>
#include <openssl/evp.h>
#include <openssl/hmac.h>
#include <openssl/sha.h>
+#include <string.h>
-#include <phosphor-logging/log.hpp>
-
-using namespace phosphor::logging;
+#include <phosphor-logging/lg2.hpp>
namespace cipher
{
@@ -25,7 +25,7 @@
if (HMAC(EVP_sha1(), userKey.data(), userKey.size(), input.data(),
input.size(), output.data(), &mdLen) == NULL)
{
- log<level::ERR>("Generate HMAC failed");
+ lg2::error("Generate HMAC failed: {ERROR}", "ERROR", strerror(errno));
output.resize(0);
}
@@ -41,7 +41,8 @@
if (HMAC(EVP_sha1(), sessionIntegrityKey.data(), SHA_DIGEST_LENGTH,
input.data(), input.size(), output.data(), &mdLen) == NULL)
{
- log<level::ERR>("Generate Session Integrity Key failed");
+ lg2::error("Generate Session Integrity Key failed: {ERROR}", "ERROR",
+ strerror(errno));
output.resize(0);
}
output.resize(integrityCheckValueLength);
@@ -58,7 +59,8 @@
if (HMAC(EVP_sha256(), userKey.data(), userKey.size(), input.data(),
input.size(), output.data(), &mdLen) == NULL)
{
- log<level::ERR>("Generate HMAC_SHA256 failed");
+ lg2::error("Generate HMAC_SHA256 failed: {ERROR}", "ERROR",
+ strerror(errno));
output.resize(0);
}
@@ -75,8 +77,9 @@
sessionIntegrityKey.size(), input.data(), input.size(),
output.data(), &mdLen) == NULL)
{
- log<level::ERR>(
- "Generate HMAC_SHA256_128 Integrity Check Value failed");
+ lg2::error(
+ "Generate HMAC_SHA256_128 Integrity Check Value failed: {ERROR}",
+ "ERROR", strerror(errno));
output.resize(0);
}
output.resize(integrityCheckValueLength);