diff --git a/Gemfile b/Gemfile index 98cf25696906c3209bd98128019aff34a1793d64..622a7e581898b7cac19266859132dcd2d0100bbb 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" +gem "amazing_print" gem "blather", git: "https://github.com/singpolyma/blather.git", branch: "ergonomics" gem "braintree" gem "dhall" @@ -12,6 +13,7 @@ gem "em-synchrony" gem "em_promise.rb", "~> 0.0.2" gem "eventmachine" gem "money-open-exchange-rates" +gem "ougai" gem "ruby-bandwidth-iris" gem "sentry-ruby" gem "statsd-instrument", git: "https://github.com/singpolyma/statsd-instrument.git", branch: "graphite" diff --git a/lib/registration.rb b/lib/registration.rb index b4f35daecd17fec5de15eecf0621201a87ec4534..a9578ad258d7011498a7b06aa413fa6ff29a240f 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -482,7 +482,7 @@ class Registration def customer_active_tel_purchased @customer.register!(@tel).catch { |e| - puts e + LOG.error "@customer.register! failed", e raise_setup_error }.then { EMPromise.all([ diff --git a/sgx_jmp.rb b/sgx_jmp.rb index a094920dc791f7de7ecbc70b07ce9da431feea3b..8c24367470f6629163a67127cb7ffcd234a8029f 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -9,11 +9,20 @@ require "date" require "dhall" require "em-hiredis" require "em_promise" +require "ougai" require "ruby-bandwidth-iris" require "sentry-ruby" require "statsd-instrument" $stdout.sync = true +LOG = Ougai::Logger.new($stdout) +LOG.level = ENV.fetch("LOG_LEVEL", "info") +LOG.formatter = Ougai::Formatters::Readable.new( + nil, + nil, + plain: !$stdout.isatty +) +LOG.info "Starting" Sentry.init @@ -103,9 +112,7 @@ end BRAINTREE = AsyncBraintree.new(**CONFIG[:braintree]) def panic(e, hub=nil) - m = e.respond_to?(:message) ? e.message : e - warn "Error raised during event loop: #{e.class}: #{m}" - warn e.backtrace if e.respond_to?(:backtrace) + LOG.fatal "Error raised during event loop: #{e.class}", e if e.is_a?(::Exception) (hub || Sentry).capture_exception(e, hint: { background: false }) else @@ -117,6 +124,7 @@ end EM.error_handler(&method(:panic)) when_ready do + LOG.info "Ready" BLATHER = self REDIS = EM::Hiredis.connect BTC_SELL_PRICES = BTCSellPrices.new(REDIS, CONFIG[:oxr_app_id]) @@ -239,7 +247,7 @@ end message :error? do |m| StatsD.increment("message_error") - puts "MESSAGE ERROR: #{m.inspect}" + LOG.error "MESSAGE ERROR", stanza: m end class SessionManager