[thrift] erlang: log more tTransportExceptions
authorChristopher Piro <cpiro@apache.org>
Sat, 11 Aug 2007 01:15:57 +0000 (01:15 +0000)
committerChristopher Piro <cpiro@apache.org>
Sat, 11 Aug 2007 01:15:57 +0000 (01:15 +0000)
Summary: all tTEs were being filtered from the logs; now just tTEs that come from connections closing are suppressed

Test Plan: logs my bug in channel server :)

Notes: adds logic to thrift_logger, not removes (bad news bears)

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665199 13f79535-47bb-0310-9956-ffa450edef68

lib/erl/lib/thrift/src/thrift_logger.erl

index 82ba772..12aa059 100644 (file)
 
 -include("thrift_logger.hrl").
 
+%% TODO(cpiro): either
+%% make exceptions know whether they need to be displayed
+%% or not exit with tExecptions for non-errors
+%% or "register" tExceptions with the logger (I LIKE!)
+%% ... we shouldn't need to build any specifics in here
+-include("thrift.hrl").
+-include("oop.hrl").
+-include("transport/tTransportException.hrl").
+
 %% gen_event callbacks
 -export([init/1, handle_event/2, handle_call/2, 
          handle_info/2, terminate/2, code_change/3]).
@@ -138,8 +147,20 @@ handle_event1({What, _Gleader, {Pid, Format, Data}}, State) when is_list(Format)
            [Pid, LastMessage, Obj, Reason] = Data,
 
            %% TODO: move as much logic as possible out of thrift_logger
-           Ignore = (is_tuple(Reason) andalso size(Reason) >= 1 andalso element(1, Reason) == timeout)
-               orelse error /= thrift_utils:unnest_record(Reason, tTransportException),
+           Ignore =
+               begin
+                   is_tuple(Reason) andalso
+                       size(Reason) >= 1 andalso element(1, Reason) == timeout
+               end
+               orelse
+               begin
+                   case thrift_utils:unnest_record(Reason, tTransportException) of
+                       error -> false;
+                       {ok, TTE} ->
+                           oop:get(TTE, type) == ?tTransportException_NOT_OPEN andalso
+                               oop:get(TTE, message) == "in tSocket:read/2: gen_tcp:recv"
+                   end
+               end,
 
            case Ignore of
                true ->