ClickHouse/programs/library-bridge/LibraryInterface.cpp

68 lines
2.1 KiB
C++
Raw Normal View History

#include "LibraryInterface.h"
2021-10-02 07:13:14 +00:00
#include <base/logger_useful.h>
namespace
{
2018-06-06 14:35:33 +00:00
const char DICT_LOGGER_NAME[] = "LibraryDictionarySourceExternal";
}
2021-03-13 11:09:56 +00:00
namespace ClickHouseLibrary
{
2021-03-14 11:29:02 +00:00
std::string_view LIBRARY_CREATE_NEW_FUNC_NAME = "ClickHouseDictionary_v3_libNew";
std::string_view LIBRARY_CLONE_FUNC_NAME = "ClickHouseDictionary_v3_libClone";
std::string_view LIBRARY_DELETE_FUNC_NAME = "ClickHouseDictionary_v3_libDelete";
2021-03-13 11:09:56 +00:00
2021-03-14 11:29:02 +00:00
std::string_view LIBRARY_DATA_NEW_FUNC_NAME = "ClickHouseDictionary_v3_dataNew";
std::string_view LIBRARY_DATA_DELETE_FUNC_NAME = "ClickHouseDictionary_v3_dataDelete";
2021-03-13 11:09:56 +00:00
2021-03-14 11:29:02 +00:00
std::string_view LIBRARY_LOAD_ALL_FUNC_NAME = "ClickHouseDictionary_v3_loadAll";
std::string_view LIBRARY_LOAD_IDS_FUNC_NAME = "ClickHouseDictionary_v3_loadIds";
std::string_view LIBRARY_LOAD_KEYS_FUNC_NAME = "ClickHouseDictionary_v3_loadKeys";
2021-03-13 11:09:56 +00:00
2021-03-14 11:29:02 +00:00
std::string_view LIBRARY_IS_MODIFIED_FUNC_NAME = "ClickHouseDictionary_v3_isModified";
std::string_view LIBRARY_SUPPORTS_SELECTIVE_LOAD_FUNC_NAME = "ClickHouseDictionary_v3_supportsSelectiveLoad";
2021-03-13 11:09:56 +00:00
void log(LogLevel level, CString msg)
{
2020-05-30 21:57:37 +00:00
auto & logger = Poco::Logger::get(DICT_LOGGER_NAME);
switch (level)
{
case LogLevel::TRACE:
if (logger.trace())
logger.trace(msg);
break;
case LogLevel::DEBUG:
if (logger.debug())
logger.debug(msg);
break;
case LogLevel::INFORMATION:
if (logger.information())
logger.information(msg);
break;
case LogLevel::NOTICE:
if (logger.notice())
logger.notice(msg);
break;
case LogLevel::WARNING:
if (logger.warning())
logger.warning(msg);
break;
case LogLevel::ERROR:
if (logger.error())
logger.error(msg);
break;
case LogLevel::CRITICAL:
if (logger.critical())
logger.critical(msg);
break;
case LogLevel::FATAL:
if (logger.fatal())
logger.fatal(msg);
break;
}
}
2021-03-13 11:09:56 +00:00
}