Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% -------------------------------------------------------------------
- %% @doc
- %% Utility for debugging of applications.
- %%
- %% Usage:
- %%
- %% ```
- %% 1> osint_dev:debug_app(osint).
- %% ...
- %% 2> osint_dev:debug_app([osint, jwt]).
- %% ...
- %% ```
- %% @see debug/0
- %% @see debug/1
- %% @see stop_debug/0
- %% @end
- %% -------------------------------------------------------------------
- -spec debug_app(X) -> ok when
- X :: App | [App, ...],
- App :: atom().
- debug_app(App) when is_atom(App) ->
- debug_app([App]);
- debug_app(Apps) when is_list(Apps) ->
- F =
- fun(E, AccIn) ->
- {ok, L} = application:get_key(E, modules),
- L ++ AccIn
- end,
- L = lists:foldl(F, [], Apps),
- io:format("~n[DEBUG] Modules to debugging: ~p~n", [L]),
- debug(L).
- %% -------------------------------------------------------------------
- %% @doc
- %% Utility for debugging the `drotr` application.
- %%
- %% Usage:
- %%
- %% ```
- %% 1> drotr_dev:debug().
- %% ```
- %% @see debug/1
- %% @see stop_debug/0
- %% @end
- %% -------------------------------------------------------------------
- -spec debug() -> ok.
- debug() ->
- {ok, L} = application:get_key(?APP_NAME, modules),
- io:format("~n[DEBUG] Modules to debugging: ~p~n", [L]),
- debug(L).
- %% -------------------------------------------------------------------
- %% @doc
- %% Utility for debugging of modules and/or functions.
- %%
- %% Usage:
- %%
- %% ```
- %% 1> osint_dev:debug([osint_api_v1, osint_users, osint_net_ws, osint_net_http]).
- %% ```
- %% @see stop_debug/0
- %% @end
- %% -------------------------------------------------------------------
- -spec debug(L) -> ok when
- L :: [E, ...],
- E :: Module | {Module, Function} | {Module, Function, Arity},
- Module :: atom(),
- Function :: atom(),
- Arity :: non_neg_integer().
- debug(L) ->
- F =
- fun
- (M) when is_atom(M) ->
- dbg:tp(M, '_', '_', []);
- ({M, F}) when is_atom(M), is_atom(F) ->
- dbg:tp(M, F, '_', []);
- ({M, F, A}) when is_atom(M), is_atom(F), is_integer(A) ->
- dbg:tp(M, F, A, []);
- (_) ->
- ok
- end,
- dbg:tracer(),
- lists:foreach(F, L),
- dbg:p(all, c),
- ok.
- %% -------------------------------------------------------------------
- %% @doc
- %% ...
- %% @end
- %% -------------------------------------------------------------------
- -spec stop_debug() -> ok.
- stop_debug() ->
- dbg:stop_clear().
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement