diff options
author | Saturneric <[email protected]> | 2023-02-03 13:43:55 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2023-02-03 13:43:55 +0000 |
commit | 11d32517c2f6f538209c893c6b0b24572fba1a36 (patch) | |
tree | 0dac14bcad75d9c7c5b5723dc23e6409721966b4 /src/core/function/CharsetOperator.cpp | |
parent | feat: change logging framework to spdlog (diff) | |
download | GpgFrontend-11d32517c2f6f538209c893c6b0b24572fba1a36.tar.gz GpgFrontend-11d32517c2f6f538209c893c6b0b24572fba1a36.zip |
feat: change the log style in source files
Diffstat (limited to 'src/core/function/CharsetOperator.cpp')
-rw-r--r-- | src/core/function/CharsetOperator.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/function/CharsetOperator.cpp b/src/core/function/CharsetOperator.cpp index 81c23388..5b14261f 100644 --- a/src/core/function/CharsetOperator.cpp +++ b/src/core/function/CharsetOperator.cpp @@ -28,6 +28,7 @@ #include "core/function/CharsetOperator.h" +#include <spdlog/spdlog.h> #include <unicode/ucnv.h> #include <unicode/ucsdet.h> #include <unicode/ustring.h> @@ -37,8 +38,6 @@ #include <memory> #include <string> -#include "easylogging++.h" - GpgFrontend::CharsetOperator::CharsetInfo GpgFrontend::CharsetOperator::Detect( const std::string &buffer) { const UCharsetMatch *ucm; @@ -47,17 +46,17 @@ GpgFrontend::CharsetOperator::CharsetInfo GpgFrontend::CharsetOperator::Detect( status = U_ZERO_ERROR; if (U_FAILURE(status)) { - LOG(ERROR) << "Failed to open charset detector: " << u_errorName(status); + SPDLOG_ERROR("failed to open charset detector: {}", u_errorName(status)); return {"unknown", "unknown", 0}; } - LOG(INFO) << "Detecting charset buffer:" << buffer.size() << "bytes"; + SPDLOG_INFO("detecting charset buffer: {} bytes", buffer.size()); status = U_ZERO_ERROR; ucsdet_setText(csd, buffer.data(), buffer.size(), &status); if (U_FAILURE(status)) { - LOG(ERROR) << "Failed to set text to charset detector: " - << u_errorName(status); + SPDLOG_ERROR("failed to set text to charset detector: {}", + u_errorName(status)); return {"unknown", "unknown", 0}; } @@ -78,7 +77,7 @@ GpgFrontend::CharsetOperator::CharsetInfo GpgFrontend::CharsetOperator::Detect( const char *language = ucsdet_getLanguage(ucm, &status); if (U_FAILURE(status)) return {name, "unknown", confidence}; - LOG(INFO) << "Detected charset: " << name << language << confidence; + SPDLOG_INFO("Detected charset: {} {} {}", name, language, confidence); return {name, language, confidence}; } @@ -89,14 +88,14 @@ bool GpgFrontend::CharsetOperator::Convert2Utf8(const std::string &buffer, const auto from_encode = std::string("utf-8"); const auto to_encode = from_charset_name; - LOG(INFO) << "Converting buffer:" << buffer.size(); + SPDLOG_INFO("Converting buffer: {}", buffer.size()); // test if the charset is supported UConverter *conv = ucnv_open(from_encode.c_str(), &status); ucnv_close(conv); if (U_FAILURE(status)) { - LOG(ERROR) << "Failed to open converter: " << u_errorName(status) << ":" - << from_encode; + SPDLOG_ERROR("failed to open converter: {}, from encode: {}", + u_errorName(status), from_encode); return false; } @@ -104,8 +103,8 @@ bool GpgFrontend::CharsetOperator::Convert2Utf8(const std::string &buffer, conv = ucnv_open(to_encode.c_str(), &status); ucnv_close(conv); if (U_FAILURE(status)) { - LOG(ERROR) << "Failed to open converter: " << u_errorName(status) << ":" - << to_encode; + SPDLOG_ERROR("failed to open converter: {}, to encode: {}", + u_errorName(status), to_encode); return false; } @@ -127,10 +126,10 @@ bool GpgFrontend::CharsetOperator::Convert2Utf8(const std::string &buffer, } if (U_FAILURE(status)) { - LOG(ERROR) << "Failed to convert to utf-8: " << u_errorName(status); + SPDLOG_ERROR("failed to convert to utf-8: {}", u_errorName(status)); return false; } - LOG(INFO) << "Converted buffer:" << out_buffer.size() << "bytes"; + SPDLOG_INFO("converted buffer: {} bytes", out_buffer.size()); return true; }
\ No newline at end of file |