refactor: remove redundant IndexLogger (#652)

This commit is contained in:
ZeFeng Yin 2026-08-05 10:51:18 +08:00 committed by GitHub
parent 6eed986ac5
commit 9ff5db33db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 67 additions and 343 deletions

View File

@ -21,7 +21,7 @@
#include <iostream>
#include <ailego/io/io_backend_def.h>
#include <zvec/ailego/io/io_backend.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/ailego/logger/logger.h>
#define MAX_EVENTS 1024

View File

@ -17,9 +17,9 @@
#include <cstdint>
#include <utility>
#include <utility/sparse_utility.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/time_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_logger.h>
#include "flat_sparse_index_format.h"
#include "flat_sparse_utility.h"
@ -335,4 +335,4 @@ int FlatSparseBuilder::dump_mapping(const std::vector<uint64_t> &keys,
INDEX_FACTORY_REGISTER_BUILDER(FlatSparseBuilder);
} // namespace core
} // namespace zvec
} // namespace zvec

View File

@ -16,7 +16,7 @@
#include <string>
#include <utility/sparse_utility.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_meta.h>
#include "flat_sparse_streamer_entity.h"

View File

@ -13,8 +13,8 @@
// limitations under the License.
#include "flat_sparse_searcher_entity.h"
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_helper.h>
#include <zvec/core/framework/index_logger.h>
#include "flat_sparse_utility.h"
namespace zvec {
@ -238,4 +238,4 @@ uint64_t FlatSparseSearcherEntity::get_key(node_id_t id) const {
}
} // namespace core
} // namespace zvec
} // namespace zvec

View File

@ -19,9 +19,9 @@
#include <utility>
#include <ailego/utility/memory_helper.h>
#include <zvec/ailego/internal/platform.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/time_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_logger.h>
#include "flat_sparse_index_format.h"
#include "flat_sparse_utility.h"

View File

@ -15,10 +15,10 @@
#include <chrono>
#include <random>
#include <zvec/ailego/hash/crc32c.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/time_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_helper.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/framework/index_streamer.h>
namespace zvec {

View File

@ -20,9 +20,9 @@
#include <mutex>
#include <ailego/utility/memory_helper.h>
#include <zvec/ailego/internal/platform.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/string_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/framework/index_storage.h>
#include <zvec/core/framework/index_streamer.h>

View File

@ -16,9 +16,9 @@
#include <random>
#include <zvec/ailego/hash/crc32c.h>
#include <zvec/ailego/utility/time_helper.h>
#include "zvec/ailego/logger/logger.h"
#include "zvec/core/framework/index_error.h"
#include "zvec/core/framework/index_helper.h"
#include "zvec/core/framework/index_logger.h"
#include "zvec/core/framework/index_streamer.h"
namespace zvec {

View File

@ -22,8 +22,8 @@
#include <ailego/utility/memory_helper.h>
#include <zvec/ailego/internal/platform.h>
#include <zvec/ailego/utility/string_helper.h>
#include "zvec/ailego/logger/logger.h"
#include "zvec/core/framework/index_error.h"
#include "zvec/core/framework/index_logger.h"
#include "zvec/core/framework/index_storage.h"
#include "zvec/core/framework/index_streamer.h"

View File

@ -15,8 +15,8 @@
#include "rabitq_utils.h"
#include <string>
#include <zvec/ailego/hash/crc32c.h>
#include "zvec/ailego/logger/logger.h"
#include "zvec/core/framework/index_error.h"
#include "zvec/core/framework/index_logger.h"
namespace zvec {
namespace core {

View File

@ -15,9 +15,9 @@
#include <iostream>
#include <thread>
#include <ailego/pattern/defer.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_factory.h>
#include <zvec/core/framework/index_logger.h>
#include "hnsw_sparse_algorithm.h"
#include "hnsw_sparse_params.h"
@ -525,4 +525,4 @@ int HnswSparseBuilder::build(IndexThreads::Pointer threads,
INDEX_FACTORY_REGISTER_BUILDER(HnswSparseBuilder);
} // namespace core
} // namespace zvec
} // namespace zvec

View File

@ -15,10 +15,10 @@
#include <chrono>
#include <random>
#include <zvec/ailego/hash/crc32c.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/time_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_helper.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/framework/index_streamer.h>
namespace zvec {

View File

@ -20,9 +20,9 @@
#include <mutex>
#include <ailego/utility/memory_helper.h>
#include <zvec/ailego/internal/platform.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/string_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/framework/index_storage.h>
#include <zvec/core/framework/index_streamer.h>

View File

@ -35,23 +35,6 @@ std::vector<std::string> IndexFactory::AllMetrics(void) {
return ailego::Factory<IndexMetric>::Classes();
}
IndexLogger::Pointer IndexFactory::CreateLogger(const std::string &name) {
IndexLogger::Pointer obj =
ailego::Factory<IndexLogger>::MakeShared(name.c_str());
if (obj) {
obj->set_name(name);
}
return obj;
}
bool IndexFactory::HasLogger(const std::string &name) {
return ailego::Factory<IndexLogger>::Has(name.c_str());
}
std::vector<std::string> IndexFactory::AllLoggers(void) {
return ailego::Factory<IndexLogger>::Classes();
}
IndexDumper::Pointer IndexFactory::CreateDumper(const std::string &name) {
IndexDumper::Pointer obj =
ailego::Factory<IndexDumper>::MakeShared(name.c_str());

View File

@ -1,72 +0,0 @@
// Copyright 2025-present the zvec project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <iostream>
#include <sstream>
#include <thread>
#include <zvec/ailego/io/file.h>
#include <zvec/ailego/utility/time_helper.h>
#include <zvec/core/framework/index_logger.h>
namespace zvec {
namespace core {
const int IndexLogger::LEVEL_DEBUG = 0;
const int IndexLogger::LEVEL_INFO = 1;
const int IndexLogger::LEVEL_WARN = 2;
const int IndexLogger::LEVEL_ERROR = 3;
const int IndexLogger::LEVEL_FATAL = 4;
/*! Console Logger
*/
struct ConsoleLogger : public IndexLogger {
//! Initialize Logger
int init(const zvec::ailego::Params &) override {
return 0;
}
//! Cleanup Logger
int cleanup(void) override {
return 0;
}
//! Log Message
void log(int level, const char *file, int line, const char *format,
va_list args) override {
char buffer[8192];
std::ostringstream stream;
ailego::Realtime::Localtime(buffer, sizeof(buffer));
stream << '[' << LevelString(level) << ' ' << buffer << ' '
<< std::this_thread::get_id() << ' ' << ailego::File::BaseName(file)
<< ':' << line << "] ";
vsnprintf(buffer, sizeof(buffer), format, args);
stream << buffer << '\n';
if (level <= LEVEL_INFO) {
std::cout << stream.str() << std::flush;
} else {
std::cerr << stream.str() << std::flush;
}
}
};
//! Logger Level
int IndexLoggerBroker::logger_level_ = 0;
//! Logger
IndexLogger::Pointer IndexLoggerBroker::logger_(new ConsoleLogger);
} // namespace core
} // namespace zvec

View File

@ -13,9 +13,9 @@
// limitations under the License.
#include <zvec/ailego/io/mmap_file.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/file_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/framework/index_mapping.h>
#include "ailego/utility/memory_helper.h"

View File

@ -20,10 +20,10 @@
#include <string>
#include <utility>
#include <vector>
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_converter.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_holder.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/interface/index_param.h>
namespace zvec::core_interface {

View File

@ -14,13 +14,13 @@
#include "mixed_streamer_reducer.h"
#include <ailego/pattern/defer.h>
#include <utility/sparse_utility.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/file_helper.h>
#include <zvec/ailego/utility/string_helper.h>
#include <zvec/ailego/utility/time_helper.h>
#include <zvec/core/framework/index_context.h>
#include <zvec/core/framework/index_factory.h>
#include <zvec/core/framework/index_holder.h>
#include <zvec/core/framework/index_logger.h>
#include "mixed_reducer/mixed_reducer_params.h"
namespace zvec {

View File

@ -16,8 +16,8 @@
#include <cstring>
#include <vector>
#include <zvec/ailego/hash/crc32c.h>
#include "zvec/ailego/logger/logger.h"
#include "zvec/core/framework/index_error.h"
#include "zvec/core/framework/index_logger.h"
#include "fht_rotator.h"
#include "matrix_rotator.h"

View File

@ -17,8 +17,8 @@
#include <cmath>
#include <numeric>
#include <vector>
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_document.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/framework/index_meta.h>
namespace zvec {

View File

@ -23,8 +23,8 @@
#include <ailego/container/bloom_filter.h>
#include <ailego/utility/bitset_helper.h>
#include <zvec/ailego/internal/platform.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_logger.h>
namespace zvec {
namespace core {

View File

@ -21,7 +21,7 @@
#include <arrow/status.h>
#include <arrow/table.h>
#include <parquet/arrow/reader.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/ailego/logger/logger.h>
namespace zvec {

View File

@ -14,12 +14,12 @@
#pragma once
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/pattern/factory.h>
#include <zvec/core/framework/index_builder.h>
#include <zvec/core/framework/index_cluster.h>
#include <zvec/core/framework/index_converter.h>
#include <zvec/core/framework/index_dumper.h>
#include <zvec/core/framework/index_logger.h>
#include <zvec/core/framework/index_metric.h>
#include <zvec/core/framework/index_reducer.h>
#include <zvec/core/framework/index_refiner.h>
@ -50,15 +50,6 @@ struct IndexFactory {
//! Retrieve all Metric classes
static std::vector<std::string> AllMetrics(void);
//! Create a index logger by name
static IndexLogger::Pointer CreateLogger(const std::string &name);
//! Test if the logger is exist
static bool HasLogger(const std::string &name);
//! Retrieve all logger classes
static std::vector<std::string> AllLoggers(void);
//! Create a index dumper by name
static IndexDumper::Pointer CreateDumper(const std::string &name);
@ -193,14 +184,6 @@ struct IndexFactory {
#define INDEX_FACTORY_REGISTER_METRIC(__IMPL__, ...) \
INDEX_FACTORY_REGISTER_METRIC_ALIAS(__IMPL__, __IMPL__, ##__VA_ARGS__)
//! Register Index Logger
#define INDEX_FACTORY_REGISTER_LOGGER_ALIAS(__NAME__, __IMPL__, ...) \
AILEGO_FACTORY_REGISTER(__NAME__, IndexLogger, __IMPL__, ##__VA_ARGS__)
//! Register Index Logger
#define INDEX_FACTORY_REGISTER_LOGGER(__IMPL__, ...) \
INDEX_FACTORY_REGISTER_LOGGER_ALIAS(__IMPL__, __IMPL__, ##__VA_ARGS__)
//! Register Index Dumper
#define INDEX_FACTORY_REGISTER_DUMPER_ALIAS(__NAME__, __IMPL__, ...) \
AILEGO_FACTORY_REGISTER(__NAME__, IndexDumper, __IMPL__, ##__VA_ARGS__)

View File

@ -1,169 +0,0 @@
// Copyright 2025-present the zvec project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <cstdarg>
#include <memory>
#include <zvec/ailego/container/params.h>
#include <zvec/ailego/logger/logger.h>
#include "index_module.h"
#define ZVEC_LOG_IMPL(level, format, ...) \
do { \
if (zvec::core::IndexLoggerBroker::IsLevelEnabled(level)) { \
zvec::core::IndexLoggerBroker::Log(level, __FILE__, __LINE__, format, \
##__VA_ARGS__); \
} \
} while (0)
//! Log Debug Message
#ifndef LOG_DEBUG
#define LOG_DEBUG(format, ...) \
ZVEC_LOG_IMPL(zvec::core::IndexLogger::LEVEL_DEBUG, format, ##__VA_ARGS__)
#endif
//! Log Information Message
#ifndef LOG_INFO
#define LOG_INFO(format, ...) \
ZVEC_LOG_IMPL(zvec::core::IndexLogger::LEVEL_INFO, format, ##__VA_ARGS__)
#endif
//! Log Warn Message
#ifndef LOG_WARN
#define LOG_WARN(format, ...) \
ZVEC_LOG_IMPL(zvec::core::IndexLogger::LEVEL_WARN, format, ##__VA_ARGS__)
#endif
//! Log Error Message
#ifndef LOG_ERROR
#define LOG_ERROR(format, ...) \
ZVEC_LOG_IMPL(zvec::core::IndexLogger::LEVEL_ERROR, format, ##__VA_ARGS__)
#endif
//! Log Fatal Message
#ifndef LOG_FATAL
#define LOG_FATAL(format, ...) \
ZVEC_LOG_IMPL(zvec::core::IndexLogger::LEVEL_FATAL, format, ##__VA_ARGS__)
#endif
namespace zvec {
namespace core {
/*! Index Logger
*/
struct IndexLogger : public IndexModule {
//! Index Logger Pointer
typedef std::shared_ptr<IndexLogger> Pointer;
static const int LEVEL_DEBUG;
static const int LEVEL_INFO;
static const int LEVEL_WARN;
static const int LEVEL_ERROR;
static const int LEVEL_FATAL;
//! Retrieve string of level
static const char *LevelString(int level) {
static const char *info[] = {"DEBUG", " INFO", " WARN", "ERROR", "FATAL"};
if (level < (int)(sizeof(info) / sizeof(info[0]))) {
return info[level];
}
return "";
}
//! Retrieve symbol of level
static char LevelSymbol(int level) {
static const char info[5] = {'D', 'I', 'W', 'E', 'F'};
if (level < (int)(sizeof(info) / sizeof(info[0]))) {
return info[level];
}
return ' ';
}
//! Destructor
~IndexLogger(void) override {}
//! Initialize Logger
virtual int init(const zvec::ailego::Params &params) = 0;
//! Cleanup Logger
virtual int cleanup(void) = 0;
//! Log Message
virtual void log(int level, const char *file, int line, const char *format,
va_list args) = 0;
};
/*! Index Logger Broker
*/
class IndexLoggerBroker {
public:
//! Register Logger
static IndexLogger::Pointer Register(IndexLogger::Pointer logger) {
IndexLogger::Pointer ret = std::move(logger_);
logger_ = std::move(logger);
return ret;
}
//! Register Logger with init params
static int Register(IndexLogger::Pointer logger,
const ailego::Params &params) {
//! Cleanup the previous, before initizlizing the new one
if (logger_) {
logger_->cleanup();
}
logger_ = std::move(logger);
return logger_->init(params);
}
//! Unregister Logger
static void Unregister(void) {
logger_ = nullptr;
}
//! Set Level of Logger
static void SetLevel(int level) {
logger_level_ = level;
}
//! Check if log level is enabled
static bool IsLevelEnabled(int level) {
return logger_level_ <= level && logger_;
}
//! Log Message
AILEGO_PRINTF_FORMAT(4, 5)
static void Log(int level, const char *file, int line, const char *format,
...) {
if (IsLevelEnabled(level)) {
va_list args;
va_start(args, format);
logger_->log(level, file, line, format, args);
va_end(args);
}
}
private:
//! Disable them
IndexLoggerBroker(void) = delete;
IndexLoggerBroker(const IndexLoggerBroker &) = delete;
IndexLoggerBroker(IndexLoggerBroker &&) = delete;
//! Members
static int logger_level_;
static IndexLogger::Pointer logger_;
};
} // namespace core
} // namespace zvec

View File

@ -15,10 +15,10 @@
#pragma once
#include <map>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/type_helper.h>
#include <zvec/core/framework/index_error.h>
#include <zvec/core/framework/index_format.h>
#include <zvec/core/framework/index_logger.h>
namespace zvec {
namespace core {

View File

@ -17,8 +17,8 @@
#include <cstring>
#include <vector>
#include <ailego/math/normalizer.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_factory.h>
#include <zvec/core/framework/index_logger.h>
#include "core/quantizer/record_quantizer.h"
namespace zvec {

View File

@ -29,7 +29,7 @@ static void DoErrLogging() {
LOG_ERROR("DoErrLogging: %d", ++err_log_count);
}
TEST(IndexLogger, General) {
TEST(Logger, General) {
ASSERT_TRUE(ailego::Factory<Logger>::Has("ConsoleLogger"));
for (int i = 0; i < 10; ++i) {
@ -64,4 +64,4 @@ TEST(IndexLogger, General) {
LOG_WARN("%s", "LOG_WARN");
LOG_ERROR("%s", "LOG_ERROR");
LOG_FATAL("%s", "LOG_FATAL");
}
}

View File

@ -20,6 +20,7 @@
#include <ailego/utility/math_helper.h>
#include <gtest/gtest.h>
#include <zvec/ailego/container/vector.h>
#include <zvec/ailego/logger/logger.h>
#include "tests/test_util.h"
#include "zvec/core/framework/index_factory.h"
#include "zvec/core/framework/index_meta.h"
@ -82,7 +83,7 @@ void FlatSparseSearcherTest::generate_sparse_data(
void FlatSparseSearcherTest::SetUp(void) {
IndexLoggerBroker::SetLevel(2);
LoggerBroker::SetLevel(Logger::LEVEL_WARN);
index_meta_ptr_.reset(new IndexMeta(IndexMeta::MetaType::MT_SPARSE,
IndexMeta::DataType::DT_FP32));
@ -816,4 +817,4 @@ TEST_F(FlatSparseSearcherTest, TestMultiThread) {
#if defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif
#endif

View File

@ -21,6 +21,7 @@
#include <ailego/utility/memory_helper.h>
#include <algorithm/flat_sparse/flat_sparse_utility.h>
#include <gtest/gtest.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/core/framework/index_framework.h>
#include <zvec/core/framework/index_streamer.h>
#include "tests/test_util.h"
@ -83,7 +84,7 @@ void FlatSparseStreamerTest::generate_sparse_data(
void FlatSparseStreamerTest::SetUp(void) {
IndexLoggerBroker::SetLevel(2);
LoggerBroker::SetLevel(Logger::LEVEL_WARN);
index_meta_ptr_.reset(new IndexMeta(IndexMeta::MetaType::MT_SPARSE,
IndexMeta::DataType::DT_FP32));
@ -1723,4 +1724,4 @@ TEST_F(FlatSparseStreamerTest, TestAddAndSearchWithID) {
#if defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif
#endif

View File

@ -817,17 +817,16 @@ int main(int argc, char *argv[]) {
}
auto config_common = config_node["IndexCommon"];
map<string, int> LOG_LEVEL = {{"debug", IndexLogger::LEVEL_DEBUG},
{"info", IndexLogger::LEVEL_INFO},
{"warn", IndexLogger::LEVEL_WARN},
{"error", IndexLogger::LEVEL_ERROR},
{"fatal", IndexLogger::LEVEL_FATAL}};
map<string, int> LOG_LEVEL = {{"debug", zvec::ailego::Logger::LEVEL_DEBUG},
{"info", zvec::ailego::Logger::LEVEL_INFO},
{"warn", zvec::ailego::Logger::LEVEL_WARN},
{"error", zvec::ailego::Logger::LEVEL_ERROR},
{"fatal", zvec::ailego::Logger::LEVEL_FATAL}};
string log_level = config_common["LogLevel"]
? config_common["LogLevel"].as<string>()
: "debug";
transform(log_level.begin(), log_level.end(), log_level.begin(), ::tolower);
if (LOG_LEVEL.find(log_level) != LOG_LEVEL.end()) {
IndexLoggerBroker::SetLevel(LOG_LEVEL[log_level]);
zvec::ailego::LoggerBroker::SetLevel(LOG_LEVEL[log_level]);
}

View File

@ -15,6 +15,7 @@
#include <signal.h>
#include <iostream>
#include <ailego/container/bitmap.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/utility/time_helper.h>
#include "zvec/ailego/utility/string_helper.h"
#include "zvec/core/framework/index_plugin.h"
@ -877,11 +878,11 @@ int main(int argc, char *argv[]) {
}
auto config_common = config_node["SearcherCommon"];
map<string, int> LOG_LEVEL = {{"debug", IndexLogger::LEVEL_DEBUG},
{"info", IndexLogger::LEVEL_INFO},
{"warn", IndexLogger::LEVEL_WARN},
{"error", IndexLogger::LEVEL_ERROR},
{"fatal", IndexLogger::LEVEL_FATAL}};
map<string, int> LOG_LEVEL = {{"debug", Logger::LEVEL_DEBUG},
{"info", Logger::LEVEL_INFO},
{"warn", Logger::LEVEL_WARN},
{"error", Logger::LEVEL_ERROR},
{"fatal", Logger::LEVEL_FATAL}};
string log_level = config_common["LogLevel"]
? config_common["LogLevel"].as<string>()
: "debug";

View File

@ -29,7 +29,6 @@
#include "zvec/ailego/logger/logger.h"
#include "zvec/core/framework/index_dumper.h"
#include "zvec/core/framework/index_factory.h"
#include "zvec/core/framework/index_logger.h"
#include "zvec/core/framework/index_plugin.h"
#include "zvec/core/framework/index_provider.h"
#include "zvec/core/framework/index_reformer.h"
@ -1313,11 +1312,11 @@ int main(int argc, char *argv[]) {
}
auto config_common = config_root["BuilderCommon"];
map<string, int> LOG_LEVEL = {{"debug", IndexLogger::LEVEL_DEBUG},
{"info", IndexLogger::LEVEL_INFO},
{"warn", IndexLogger::LEVEL_WARN},
{"error", IndexLogger::LEVEL_ERROR},
{"fatal", IndexLogger::LEVEL_FATAL}};
map<string, int> LOG_LEVEL = {{"debug", zvec::ailego::Logger::LEVEL_DEBUG},
{"info", zvec::ailego::Logger::LEVEL_INFO},
{"warn", zvec::ailego::Logger::LEVEL_WARN},
{"error", zvec::ailego::Logger::LEVEL_ERROR},
{"fatal", zvec::ailego::Logger::LEVEL_FATAL}};
string log_level = config_common["LogLevel"]
? config_common["LogLevel"].as<string>()
@ -1325,7 +1324,6 @@ int main(int argc, char *argv[]) {
transform(log_level.begin(), log_level.end(), log_level.begin(), ::tolower);
if (LOG_LEVEL.find(log_level) != LOG_LEVEL.end()) {
IndexLoggerBroker::SetLevel(LOG_LEVEL[log_level]);
zvec::ailego::LoggerBroker::SetLevel(LOG_LEVEL[log_level]);
}

View File

@ -24,9 +24,9 @@
#include "algorithm/hnsw_rabitq/rabitq_converter.h"
#include "algorithm/hnsw_rabitq/rabitq_reformer.h"
#endif
#include "zvec/ailego/logger/logger.h"
#include "zvec/core/framework/index_dumper.h"
#include "zvec/core/framework/index_factory.h"
#include "zvec/core/framework/index_logger.h"
#include "zvec/core/framework/index_plugin.h"
#include "zvec/core/framework/index_provider.h"
#include "zvec/core/framework/index_reformer.h"
@ -1219,11 +1219,11 @@ int main(int argc, char *argv[]) {
}
auto config_common = config_root["BuilderCommon"];
map<string, int> LOG_LEVEL = {{"debug", IndexLogger::LEVEL_DEBUG},
{"info", IndexLogger::LEVEL_INFO},
{"warn", IndexLogger::LEVEL_WARN},
{"error", IndexLogger::LEVEL_ERROR},
{"fatal", IndexLogger::LEVEL_FATAL}};
map<string, int> LOG_LEVEL = {{"debug", zvec::ailego::Logger::LEVEL_DEBUG},
{"info", zvec::ailego::Logger::LEVEL_INFO},
{"warn", zvec::ailego::Logger::LEVEL_WARN},
{"error", zvec::ailego::Logger::LEVEL_ERROR},
{"fatal", zvec::ailego::Logger::LEVEL_FATAL}};
string log_level = config_common["LogLevel"]
? config_common["LogLevel"].as<string>()
@ -1231,7 +1231,6 @@ int main(int argc, char *argv[]) {
transform(log_level.begin(), log_level.end(), log_level.begin(), ::tolower);
if (LOG_LEVEL.find(log_level) != LOG_LEVEL.end()) {
IndexLoggerBroker::SetLevel(LOG_LEVEL[log_level]);
zvec::ailego::LoggerBroker::SetLevel(LOG_LEVEL[log_level]);
}

View File

@ -1660,17 +1660,16 @@ int main(int argc, char *argv[]) {
}
auto config_common = config_node["IndexCommon"];
map<string, int> LOG_LEVEL = {{"debug", IndexLogger::LEVEL_DEBUG},
{"info", IndexLogger::LEVEL_INFO},
{"warn", IndexLogger::LEVEL_WARN},
{"error", IndexLogger::LEVEL_ERROR},
{"fatal", IndexLogger::LEVEL_FATAL}};
map<string, int> LOG_LEVEL = {{"debug", zvec::ailego::Logger::LEVEL_DEBUG},
{"info", zvec::ailego::Logger::LEVEL_INFO},
{"warn", zvec::ailego::Logger::LEVEL_WARN},
{"error", zvec::ailego::Logger::LEVEL_ERROR},
{"fatal", zvec::ailego::Logger::LEVEL_FATAL}};
string log_level = config_common["LogLevel"]
? config_common["LogLevel"].as<string>()
: "debug";
transform(log_level.begin(), log_level.end(), log_level.begin(), ::tolower);
if (LOG_LEVEL.find(log_level) != LOG_LEVEL.end()) {
IndexLoggerBroker::SetLevel(LOG_LEVEL[log_level]);
zvec::ailego::LoggerBroker::SetLevel(LOG_LEVEL[log_level]);
}

View File

@ -20,6 +20,7 @@
#include <ailego/parallel/lock.h>
#include <zvec/ailego/hash/crc32c.h>
#include <zvec/ailego/io/file.h>
#include <zvec/ailego/logger/logger.h>
#include <zvec/ailego/parallel/thread_pool.h>
#include <zvec/ailego/utility/string_helper.h>
#include <zvec/ailego/utility/time_helper.h>
@ -1876,11 +1877,11 @@ int main(int argc, char *argv[]) {
}
auto config_common = config_node["SearcherCommon"];
map<string, int> LOG_LEVEL = {{"debug", IndexLogger::LEVEL_DEBUG},
{"info", IndexLogger::LEVEL_INFO},
{"warn", IndexLogger::LEVEL_WARN},
{"error", IndexLogger::LEVEL_ERROR},
{"fatal", IndexLogger::LEVEL_FATAL}};
map<string, int> LOG_LEVEL = {{"debug", Logger::LEVEL_DEBUG},
{"info", Logger::LEVEL_INFO},
{"warn", Logger::LEVEL_WARN},
{"error", Logger::LEVEL_ERROR},
{"fatal", Logger::LEVEL_FATAL}};
string log_level = config_common["LogLevel"]
? config_common["LogLevel"].as<string>()
: "debug";