From: Christopher Piro Date: Thu, 15 Nov 2007 06:26:31 +0000 (+0000) Subject: [thrift] fix-ups to Erlang thrift_logger X-Git-Tag: 0.2.0~1129 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=10522a7f2b9d413d97f49670e3102826833dcdcf;p=common%2Fthrift.git [thrift] fix-ups to Erlang thrift_logger Summary: * no ?INFO for every oop:call ... way too expensive * unfactor symbol/1 ... it was that way for a reason apparently * upped crash report depth to 3 Reviewed By: eletuchy Test Plan: /much/ less CPU eaten by logging Revert Plan: ok git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665343 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/erl/src/oop.erl b/lib/erl/src/oop.erl index 11be4d4e..e4de147a 100644 --- a/lib/erl/src/oop.erl +++ b/lib/erl/src/oop.erl @@ -86,7 +86,8 @@ call(Obj, Func) -> call(Obj, Func, []). call(Obj, Func, ArgsProper) -> - ?INFO("oop:call called: Obj=~p Func=~p ArgsProper=~p", [inspect(Obj), Func, ArgsProper]), + %% this is WAY too expensive + %% ?INFO("oop:call called: Obj=~p Func=~p ArgsProper=~p", [inspect(Obj), Func, ArgsProper]), case call1(Obj, Func, ArgsProper) of {ok, Value} -> Value; {error, Kind, S1} -> error(Kind, S1) diff --git a/lib/erl/src/thrift_logger.erl b/lib/erl/src/thrift_logger.erl index 31a71b99..0d0b876c 100644 --- a/lib/erl/src/thrift_logger.erl +++ b/lib/erl/src/thrift_logger.erl @@ -131,7 +131,13 @@ handle_event2(Symbol, Pid, Type, Message, State) -> % Message must be a string %% handle_event1({What, _Gleader, {Ref, Format, Data}}, State) when is_list(Format) -> - Symbol = symbol(What), + Symbol = + case What of + error -> "!!"; + warning_msg -> "**"; + info_msg -> ".."; + _Else -> "??" + end, case {Format, Data} of {?GS_TERM_FORMAT, [Ref, LastMessage, Obj, Reason]} -> @@ -174,7 +180,13 @@ handle_event1({What, _Gleader, {Ref, Format, Data}}, State) when is_list(Format) {ok, State}; handle_event1({What, _Gleader, {Pid, Type, Report}}, State) -> - Symbol = symbol(What), + Symbol = + case What of + error_report -> "!!"; + warning_report -> "**"; + info_report -> ".."; + _Else -> "??" + end, case Type of crash_report -> @@ -271,11 +283,6 @@ sformat(Format, Data) -> config(Item) -> thrift:config(Item). -symbol(error_report) -> "!!"; -symbol(warning_report) -> "**"; -symbol(info_report) -> ".."; -symbol(_Else) -> "??". - print_crash_report(Report) -> case Report of [[_,_,{error_info, XX}|_] | _] -> @@ -283,7 +290,7 @@ print_crash_report(Report) -> tTransportException -> ok; _ -> - io:format("~~~~ crash report: ~P~n", [XX, 2]) + io:format("~~~~ crash report: ~P~n", [XX, 3]) end; _ -> io:format("~~~~ crash report (?): ~p~n", [Report])