You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2017/05/12 22:29:00 UTC

thrift git commit: THRIFT-4198 Ruby should log Thrift internal errors to global logger Client: Ruby Patch: Sho Nakatani

Repository: thrift
Updated Branches:
  refs/heads/master 5862099f3 -> 9a745aa4a


THRIFT-4198 Ruby should log Thrift internal errors to global logger
Client: Ruby
Patch: Sho Nakatani <la...@gmail.com>

This closes #1252


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/9a745aa4
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/9a745aa4
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/9a745aa4

Branch: refs/heads/master
Commit: 9a745aa4a9ac1098f0ea584d0f4e85ca1f04c964
Parents: 5862099
Author: Sho Nakatani <la...@gmail.com>
Authored: Fri Apr 14 23:08:37 2017 +0900
Committer: Jens Geyer <je...@apache.org>
Committed: Sat May 13 00:28:32 2017 +0200

----------------------------------------------------------------------
 lib/rb/lib/thrift/processor.rb | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/9a745aa4/lib/rb/lib/thrift/processor.rb
----------------------------------------------------------------------
diff --git a/lib/rb/lib/thrift/processor.rb b/lib/rb/lib/thrift/processor.rb
index fd312ee..ce21e12 100644
--- a/lib/rb/lib/thrift/processor.rb
+++ b/lib/rb/lib/thrift/processor.rb
@@ -17,10 +17,18 @@
 # under the License.
 # 
 
+require 'logger'
+
 module Thrift
   module Processor
-    def initialize(handler)
+    def initialize(handler, logger=nil)
       @handler = handler
+      if logger.nil?
+        @logger = Logger.new(STDERR)
+        @logger.level = Logger::WARN
+      else
+        @logger = logger
+      end
     end
 
     def process(iprot, oprot)
@@ -30,6 +38,7 @@ module Thrift
           send("process_#{name}", seqid, iprot, oprot)
         rescue => e
           x = ApplicationException.new(ApplicationException::INTERNAL_ERROR, 'Internal error')
+          @logger.debug "Internal error : #{e.message}\n#{e.backtrace.join("\n")}"
           write_error(x, oprot, name, seqid)
         end
         true