./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 53 #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, #{}) ->
18
:-(
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
:-(
?LOG(get_loglevel(Config, Measurements),
24 #{what => EventName,
25 labels => Labels,
26
:-(
measurements => maps:remove(loglevel, Measurements)}).
27
28
:-(
get_loglevel(#{}, #{loglevel := LogLevel}) -> LogLevel;
29
:-(
get_loglevel(#{loglevel := LogLevel}, #{}) -> LogLevel;
30
:-(
get_loglevel(#{}, #{}) -> mongoose_config:get_opt([instrumentation, log, level]).
Line Hits Source