./ct_report/coverage/mongoose_instrument_log.COVER.html

1 -module(mongoose_instrument_log).
2
3 -behaviour(mongoose_instrument).
4
5 -export([config_spec/0, set_up/3, handle_event/4]).
6
7 -include("mongoose.hrl").
8 -include("mongoose_config_spec.hrl").
9
10 -spec config_spec() -> mongoose_config_spec:config_section().
11 config_spec() ->
12 82 #section{items = #{<<"level">> => #option{type = atom, validate = loglevel}},
13 defaults = #{<<"level">> => debug}}.
14
15 -spec set_up(mongoose_instrument:event_name(), mongoose_instrument:labels(),
16 mongoose_instrument:config()) -> boolean().
17 set_up(_EventName, _Labels, _Config) ->
18 200 true.
19
20 -spec handle_event(mongoose_instrument:event_name(), mongoose_instrument:labels(),
21 mongoose_instrument:config(), mongoose_instrument:measurements()) -> ok.
22 handle_event(EventName, Labels, Config, Measurements) ->
23 575 ?LOG(get_loglevel(Config, Measurements),
24 #{what => EventName,
25 labels => Labels,
26 575 measurements => maps:remove(loglevel, Measurements)}).
27
28 -spec get_loglevel(mongoose_instrument:config(), mongoose_instrument:measurements()) ->
29 logger:level().
30
:-(
get_loglevel(#{}, #{loglevel := LogLevel}) -> LogLevel;
31
:-(
get_loglevel(#{loglevel := LogLevel}, #{}) -> LogLevel;
32 575 get_loglevel(#{}, #{}) -> mongoose_config:get_opt([instrumentation, log, level]).
Line Hits Source