~singpolyma/sgx-jmp

3471f2d70821eae7eabc2b05ade10738679381be — Stephen Paul Weber 1 year, 10 months ago 6e8fb2e + d52e900
Merge branch 'logging'

* logging:
  Slightly better logging
3 files changed, 15 insertions(+), 5 deletions(-)

M Gemfile
M lib/registration.rb
M sgx_jmp.rb
M Gemfile => Gemfile +2 -0
@@ 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"

M lib/registration.rb => lib/registration.rb +1 -1
@@ 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([

M sgx_jmp.rb => sgx_jmp.rb +12 -4
@@ 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