在提升日志中组合过滤器
Combining filters in boost log
我使用 boost log 并想定义一个 组合过滤器 。我使用 boost::log::init_from_stream
从流中读取配置。在单一条件下过滤效果很好。我可以
Filter = "%Channel% = A"
只从通道 A 获取日志条目。我可以做到
Filter = "%Severity% >= warn"
仅获取严重性为警告或以上的日志条目。
问题来了:我想做这样的事情
Filter = " (%Channel% = A AND %Severity% >= warn)
OR (%Channel% = B AND %Severity% >= info)"
我找不到有关此类过滤器组合的任何文档。使用 boost::log::init_from_stream
时有没有办法做到这一点?
我找到了记录语法的文档页面:
-
filter:
condition { op condition }
op:
&
and
|
or
condition:
!condition
not condition
(filter)
%attribute_name%
%attribute_name% relation operand
relation:
>
<
=
!=
>=
<=
begins_with
ends_with
contains
matches
利用这个,题中给出的例子可以表示如下:
Filter = "(%Channel% = A & %Severity% >= warn) | (%Channel% = B & %Severity% >= info)"
我使用 boost log 并想定义一个 组合过滤器 。我使用 boost::log::init_from_stream
从流中读取配置。在单一条件下过滤效果很好。我可以
Filter = "%Channel% = A"
只从通道 A 获取日志条目。我可以做到
Filter = "%Severity% >= warn"
仅获取严重性为警告或以上的日志条目。
问题来了:我想做这样的事情
Filter = " (%Channel% = A AND %Severity% >= warn)
OR (%Channel% = B AND %Severity% >= info)"
我找不到有关此类过滤器组合的任何文档。使用 boost::log::init_from_stream
时有没有办法做到这一点?
我找到了记录语法的文档页面:
-
filter: condition { op condition } op: & and | or condition: !condition not condition (filter) %attribute_name% %attribute_name% relation operand relation: > < = != >= <= begins_with ends_with contains matches
利用这个,题中给出的例子可以表示如下:
Filter = "(%Channel% = A & %Severity% >= warn) | (%Channel% = B & %Severity% >= info)"