#include #include #include #include #include #include #include #include #include #include namespace DB { NamesAndTypesList TextLogElement::getNamesAndTypes() { auto priority_datatype = std::make_shared( DataTypeEnum8::Values { {"Fatal", static_cast(Message::PRIO_FATAL)}, {"Critical", static_cast(Message::PRIO_CRITICAL)}, {"Error", static_cast(Message::PRIO_ERROR)}, {"Warning", static_cast(Message::PRIO_WARNING)}, {"Notice", static_cast(Message::PRIO_NOTICE)}, {"Information", static_cast(Message::PRIO_INFORMATION)}, {"Debug", static_cast(Message::PRIO_DEBUG)}, {"Trace", static_cast(Message::PRIO_TRACE)}, {"Test", static_cast(Message::PRIO_TEST)}, }); return { {"event_date", std::make_shared()}, {"event_time", std::make_shared()}, {"event_time_microseconds", std::make_shared(6)}, {"microseconds", std::make_shared()}, {"thread_name", std::make_shared(std::make_shared())}, {"thread_id", std::make_shared()}, {"level", std::move(priority_datatype)}, {"query_id", std::make_shared()}, {"logger_name", std::make_shared(std::make_shared())}, {"message", std::make_shared()}, {"revision", std::make_shared()}, {"source_file", std::make_shared(std::make_shared())}, {"source_line", std::make_shared()} }; } void TextLogElement::appendToBlock(MutableColumns & columns) const { size_t i = 0; columns[i++]->insert(DateLUT::instance().toDayNum(event_time).toUnderType()); columns[i++]->insert(event_time); columns[i++]->insert(event_time_microseconds); columns[i++]->insert(microseconds); columns[i++]->insertData(thread_name.data(), thread_name.size()); columns[i++]->insert(thread_id); columns[i++]->insert(level); columns[i++]->insert(query_id); columns[i++]->insert(logger_name); columns[i++]->insert(message); columns[i++]->insert(ClickHouseRevision::getVersionRevision()); columns[i++]->insert(source_file); columns[i++]->insert(source_line); } TextLog::TextLog(ContextPtr context_, const String & database_name_, const String & table_name_, const String & storage_def_, size_t flush_interval_milliseconds_) : SystemLog(context_, database_name_, table_name_, storage_def_, flush_interval_milliseconds_) { // SystemLog methods may write text logs, so we disable logging for the text // log table to avoid recursion. log->setLevel(0); } }