summaryrefslogtreecommitdiff
path: root/lib/rb
diff options
context:
space:
mode:
authorSho Nakatani <lay.sakura@gmail.com>2017-04-14 23:08:37 +0900
committerJens Geyer <jensg@apache.org>2017-05-13 00:28:32 +0200
commit9a745aa4a9ac1098f0ea584d0f4e85ca1f04c964 (patch)
treec361e8f92e51d305689e6f2ccf65473cc573ff47 /lib/rb
parent5862099f371388b0d1c0cc8beb43efb17e017a99 (diff)
downloadthrift-9a745aa4a9ac1098f0ea584d0f4e85ca1f04c964.tar.gz
THRIFT-4198 Ruby should log Thrift internal errors to global logger
Client: Ruby Patch: Sho Nakatani <lay.sakura@gmail.com> This closes #1252
Diffstat (limited to 'lib/rb')
-rw-r--r--lib/rb/lib/thrift/processor.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/rb/lib/thrift/processor.rb b/lib/rb/lib/thrift/processor.rb
index fd312eee7..ce21e120a 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