Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 86 lines (49 sloc) 2.187 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
%%%----------------------------------------------------------------------
%%% File : yaws_debug.hrl
%%% Author : Claes Wikstrom <klacke@hyber.org>
%%% Purpose :
%%% Created : 7 Feb 2002 by Claes Wikstrom <klacke@hyber.org>
%%%----------------------------------------------------------------------

-author('klacke@hyber.org').



-define(F(Format,Args),
         lists:flatten(io_lib:format(Format,Args))).

-define(f(L), lists:flatten(L)).

-define(W(A), ?F("~w", [A])).

-define(format_record(Rec, Name),
        yaws_debug:format_record(Rec, Name, record_info(fields, Name))).



-define(Trace(What, Fmt, Args), if Trace == false ->
                                        ok;
                                   _ ->
                                        yaws_debug:dtrace(What,Fmt,Args)
                                end).



-ifdef(debug).


%% Possible Ops are, equal | neq | integer | list | {list, length, equal}
%% | greater | min | max | interval | {in, X , List}




-define(Dassert(X,Op,Y,Msg),
        yaws_debug:assert(Op,X,Y,{assert,?FILE,?LINE,Msg})).


-define(Dalert(X,Op,Y,Msg),
        yaws_debug:assert(Op,X,Y,{alert,?FILE,?LINE,Msg})).

-define(Deval(Expr),Expr).

-define(Debug(F, A),
        yaws_debug:assert([],0,0,{{debug,"DEBUG"}, ?FILE,?LINE,F, A})).


%% ease of use, just do ?Dvar(Variable)
-define(Dvar(Var), ?Debug("Var = ~p~n", [Var])).

-define(TC(L), yaws_debug:typecheck(L, ?FILE, ?LINE)).


-define(Derror(Fmt,Args),
        yaws_debug:assert([],0,0,{{debug,"ERROR"}, ?FILE,?LINE,Fmt,Args})).


-define(Dformat(Fmt,Args),
        yaws_debug:assert([],0,0,{format, ?FILE,?LINE,Fmt,Args})).


-define(Dfunassert(Fun, Msg),
        yaws_debug:assert('fun', Fun, 0, {assert,?FILE,?LINE,Msg})).

-else. %% not debug_mode

-define(DLOG(F, A), ?LOG(F, A)).
-define(Dassert(X,Op,Y,Msg),debug_disabled).
-define(Dalert(X,Op,Y,Msg),debug_disabled).
-define(Deval(Expr),debug_disabled).
-define(Debug(F, A),debug_disabled).
-define(Dvar(Var), debug_disabled).
-define(Dformat(Fmt,Args),debug_disabled).
-define(Dfunassert(Fun, Msg), debug_disabled).
-define(Derror(Fmt,Args),debug_disabled).
-define(TC(L), debug_disabled).

-endif. %% debug defined

Something went wrong with that request. Please try again.