2019-07-22 13:54:08 +00:00
|
|
|
#include <Interpreters/TextLog.h>
|
|
|
|
#include <DataTypes/DataTypeEnum.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataTypes/DataTypeDateTime.h>
|
|
|
|
#include <DataTypes/DataTypeDate.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <Common/ClickHouseRevision.h>
|
|
|
|
#include <array>
|
|
|
|
|
2019-07-22 15:09:33 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
Block TextLogElement::createBlock()
|
|
|
|
{
|
|
|
|
auto priority_datatype = std::make_shared<DataTypeEnum8>(
|
|
|
|
DataTypeEnum8::Values
|
|
|
|
{
|
2019-07-23 08:22:38 +00:00
|
|
|
{"Fatal", static_cast<Int8>(Message::PRIO_FATAL)},
|
|
|
|
{"Critical", static_cast<Int8>(Message::PRIO_CRITICAL)},
|
|
|
|
{"Error", static_cast<Int8>(Message::PRIO_ERROR)},
|
|
|
|
{"Warning", static_cast<Int8>(Message::PRIO_WARNING)},
|
|
|
|
{"Notice", static_cast<Int8>(Message::PRIO_NOTICE)},
|
|
|
|
{"Information", static_cast<Int8>(Message::PRIO_INFORMATION)},
|
|
|
|
{"Debug", static_cast<Int8>(Message::PRIO_DEBUG)},
|
|
|
|
{"Trace", static_cast<Int8>(Message::PRIO_TRACE)}
|
2019-07-22 15:09:33 +00:00
|
|
|
});
|
2019-07-22 13:54:08 +00:00
|
|
|
|
|
|
|
return
|
|
|
|
{
|
|
|
|
{std::make_shared<DataTypeDate>(), "event_date"},
|
|
|
|
{std::make_shared<DataTypeDateTime>(), "event_time"},
|
|
|
|
{std::make_shared<DataTypeUInt32>(), "microseconds"},
|
|
|
|
|
|
|
|
{std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "thread_name"},
|
|
|
|
{std::make_shared<DataTypeUInt32>(), "thread_number"},
|
|
|
|
{std::make_shared<DataTypeUInt32>(), "os_thread_id"},
|
|
|
|
|
2019-07-22 15:09:33 +00:00
|
|
|
{std::move(priority_datatype), "level"},
|
2019-07-22 13:54:08 +00:00
|
|
|
{std::make_shared<DataTypeString>(), "query_id"},
|
2019-08-12 23:47:15 +00:00
|
|
|
{std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "logger_name"},
|
2019-07-22 13:54:08 +00:00
|
|
|
{std::make_shared<DataTypeString>(), "message"},
|
|
|
|
|
2019-07-22 15:09:33 +00:00
|
|
|
{std::make_shared<DataTypeUInt32>(), "revision"},
|
|
|
|
|
2019-07-22 13:54:08 +00:00
|
|
|
{std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "source_file"},
|
|
|
|
{std::make_shared<DataTypeUInt64>(), "source_line"}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void TextLogElement::appendToBlock(Block & block) const
|
|
|
|
{
|
|
|
|
MutableColumns columns = block.mutateColumns();
|
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
|
|
|
|
columns[i++]->insert(event_time);
|
|
|
|
columns[i++]->insert(microseconds);
|
|
|
|
|
|
|
|
columns[i++]->insertData(thread_name.data(), thread_name.size());
|
|
|
|
columns[i++]->insert(thread_number);
|
|
|
|
columns[i++]->insert(os_thread_id);
|
|
|
|
|
2019-07-22 15:09:33 +00:00
|
|
|
columns[i++]->insert(level);
|
2019-07-22 13:54:08 +00:00
|
|
|
columns[i++]->insert(query_id);
|
|
|
|
columns[i++]->insert(logger_name);
|
|
|
|
columns[i++]->insert(message);
|
|
|
|
|
2019-07-22 15:09:33 +00:00
|
|
|
columns[i++]->insert(ClickHouseRevision::get());
|
|
|
|
|
2019-07-22 13:54:08 +00:00
|
|
|
columns[i++]->insert(source_file);
|
|
|
|
columns[i++]->insert(source_line);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|