woody_erlang/test/woody_ct_event_h.erl
Andrew Mayorov 4fab3f64af
Split severity off formatted event message (#152)
It's usually needed earlier than the message itself. And may even be used
to skip formatting altogether, with `msg_fun()` facility in Erlang
logger.

Simplify event handler interface which should make this module more
usable down the line.

Also use monotonic timestamps when measuring time intervals.
2021-06-22 11:01:27 +03:00

32 lines
685 B
Erlang

-module(woody_ct_event_h).
-behaviour(woody_event_handler).
-export([handle_event/4]).
-define(ESSENTIAL_META, [
event,
role,
service,
service_schema,
function,
type,
args,
metadata,
deadline,
status,
url,
code,
result
]).
-spec handle_event(
woody_event_handler:event(),
woody:rpc_id(),
woody_event_handler:event_meta(),
_Prelude
) -> _.
handle_event(Event, RpcId, Meta, Prelude) ->
{Format, Msg} = woody_event_handler:format_event(Event, Meta, RpcId, #{}),
EvMeta = woody_event_handler:format_meta(Event, Meta, ?ESSENTIAL_META),
ct:pal("~p " ++ Format ++ "~nmeta: ~p", [Prelude] ++ Msg ++ [EvMeta]).