Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
6a73cf23
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6a73cf23
编写于
1月 23, 2020
作者:
A
Azat Khuzhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add text_log.level to limit entries that goes to system.text_log table
v2: use INT_MAX as default (since 0 is none)
上级
c0ba5ed0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
26 deletion
+40
-26
dbms/programs/server/Server.cpp
dbms/programs/server/Server.cpp
+5
-1
dbms/programs/server/config.xml
dbms/programs/server/config.xml
+2
-0
libs/libloggers/loggers/Loggers.cpp
libs/libloggers/loggers/Loggers.cpp
+3
-2
libs/libloggers/loggers/Loggers.h
libs/libloggers/loggers/Loggers.h
+3
-1
libs/libloggers/loggers/OwnSplitChannel.cpp
libs/libloggers/loggers/OwnSplitChannel.cpp
+25
-21
libs/libloggers/loggers/OwnSplitChannel.h
libs/libloggers/loggers/OwnSplitChannel.h
+2
-1
未找到文件。
dbms/programs/server/Server.cpp
浏览文件 @
6a73cf23
...
...
@@ -881,7 +881,11 @@ int Server::main(const std::vector<std::string> & /*args*/)
for
(
auto
&
server
:
servers
)
server
->
start
();
setTextLog
(
global_context
->
getTextLog
());
{
String
level_str
=
config
().
getString
(
"text_log.level"
,
""
);
int
level
=
level_str
.
empty
()
?
INT_MAX
:
Poco
::
Logger
::
parseLevel
(
level_str
);
setTextLog
(
global_context
->
getTextLog
(),
level
);
}
buildLoggers
(
config
(),
logger
());
main_config_reloader
->
start
();
...
...
dbms/programs/server/config.xml
浏览文件 @
6a73cf23
...
...
@@ -389,10 +389,12 @@
<!-- Uncomment to write text log into table.
Text log contains all information from usual server log but stores it in structured and efficient way.
The level of the messages that goes to the table can be limited (<level>), if not specified all messages will go to the table.
<text_log>
<database>system</database>
<table>text_log</table>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
<level></level>
</text_log>
-->
...
...
libs/libloggers/loggers/Loggers.cpp
浏览文件 @
6a73cf23
...
...
@@ -27,16 +27,17 @@ static std::string createDirectory(const std::string & file)
return
path
.
toString
();
};
void
Loggers
::
setTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
)
void
Loggers
::
setTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
,
int
max_priority
)
{
text_log
=
log
;
text_log_max_priority
=
max_priority
;
}
void
Loggers
::
buildLoggers
(
Poco
::
Util
::
AbstractConfiguration
&
config
,
Poco
::
Logger
&
logger
/*_root*/
,
const
std
::
string
&
cmd_name
)
{
if
(
split
)
if
(
auto
log
=
text_log
.
lock
())
split
->
addTextLog
(
log
);
split
->
addTextLog
(
log
,
text_log_max_priority
);
auto
current_logger
=
config
.
getString
(
"logger"
,
""
);
if
(
config_logger
==
current_logger
)
...
...
libs/libloggers/loggers/Loggers.h
浏览文件 @
6a73cf23
...
...
@@ -24,7 +24,7 @@ public:
return
layer
;
/// layer setted in inheritor class BaseDaemonApplication.
}
void
setTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
);
void
setTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
,
int
max_priority
);
protected:
std
::
optional
<
size_t
>
layer
;
...
...
@@ -38,5 +38,7 @@ private:
std
::
string
config_logger
;
std
::
weak_ptr
<
DB
::
TextLog
>
text_log
;
int
text_log_max_priority
=
-
1
;
Poco
::
AutoPtr
<
DB
::
OwnSplitChannel
>
split
;
};
libs/libloggers/loggers/OwnSplitChannel.cpp
浏览文件 @
6a73cf23
...
...
@@ -70,34 +70,37 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)
}
/// Also log to system.text_log table
TextLogElement
elem
;
/// Also log to system.text_log table, if message is not too noisy
if
(
text_log_max_priority
&&
msg
.
getPriority
()
<=
text_log_max_priority
)
{
TextLogElement
elem
;
elem
.
event_time
=
msg_ext
.
time_seconds
;
elem
.
microseconds
=
msg_ext
.
time_microseconds
;
elem
.
event_time
=
msg_ext
.
time_seconds
;
elem
.
microseconds
=
msg_ext
.
time_microseconds
;
elem
.
thread_name
=
getThreadName
();
elem
.
thread_number
=
msg_ext
.
thread_number
;
elem
.
thread_name
=
getThreadName
();
elem
.
thread_number
=
msg_ext
.
thread_number
;
if
(
CurrentThread
::
isInitialized
())
elem
.
os_thread_id
=
CurrentThread
::
get
().
os_thread_id
;
else
elem
.
os_thread_id
=
0
;
if
(
CurrentThread
::
isInitialized
())
elem
.
os_thread_id
=
CurrentThread
::
get
().
os_thread_id
;
else
elem
.
os_thread_id
=
0
;
elem
.
query_id
=
msg_ext
.
query_id
;
elem
.
query_id
=
msg_ext
.
query_id
;
elem
.
message
=
msg
.
getText
();
elem
.
logger_name
=
msg
.
getSource
();
elem
.
level
=
msg
.
getPriority
();
elem
.
message
=
msg
.
getText
();
elem
.
logger_name
=
msg
.
getSource
();
elem
.
level
=
msg
.
getPriority
();
if
(
msg
.
getSourceFile
()
!=
nullptr
)
elem
.
source_file
=
msg
.
getSourceFile
();
if
(
msg
.
getSourceFile
()
!=
nullptr
)
elem
.
source_file
=
msg
.
getSourceFile
();
elem
.
source_line
=
msg
.
getSourceLine
();
elem
.
source_line
=
msg
.
getSourceLine
();
std
::
lock_guard
<
std
::
mutex
>
lock
(
text_log_mutex
);
if
(
auto
log
=
text_log
.
lock
())
log
->
add
(
elem
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
text_log_mutex
);
if
(
auto
log
=
text_log
.
lock
())
log
->
add
(
elem
);
}
}
...
...
@@ -106,10 +109,11 @@ void OwnSplitChannel::addChannel(Poco::AutoPtr<Poco::Channel> channel)
channels
.
emplace_back
(
std
::
move
(
channel
),
dynamic_cast
<
ExtendedLogChannel
*>
(
channel
.
get
()));
}
void
OwnSplitChannel
::
addTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
)
void
OwnSplitChannel
::
addTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
,
int
max_priority
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
text_log_mutex
);
text_log
=
log
;
text_log_max_priority
=
max_priority
;
}
}
libs/libloggers/loggers/OwnSplitChannel.h
浏览文件 @
6a73cf23
...
...
@@ -20,7 +20,7 @@ public:
/// Adds a child channel
void
addChannel
(
Poco
::
AutoPtr
<
Poco
::
Channel
>
channel
);
void
addTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
);
void
addTextLog
(
std
::
shared_ptr
<
DB
::
TextLog
>
log
,
int
max_priority
);
private:
void
logSplit
(
const
Poco
::
Message
&
msg
);
...
...
@@ -33,6 +33,7 @@ private:
std
::
mutex
text_log_mutex
;
std
::
weak_ptr
<
DB
::
TextLog
>
text_log
;
int
text_log_max_priority
=
-
1
;
};
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录