Skip to content

Commit

Permalink
feat(log): configure raven log backend
Browse files Browse the repository at this point in the history
  • Loading branch information
caspiano committed Jan 7, 2021
1 parent 5e06c84 commit 48dddec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,30 @@ require "raven/integrations/action-controller"

# Logging configuration
log_level = PlaceOS::Api.production? ? Log::Severity::Info : Log::Severity::Debug
::Log.setup "*", log_level, PlaceOS::Api::LOG_BACKEND
::Log.builder.bind "action-controller.*", log_level, PlaceOS::Api::LOG_BACKEND
::Log.builder.bind "rest-api.*", log_level, PlaceOS::Api::LOG_BACKEND

::Log.setup do |config|
# Bind IO backend
config.bind "*", log_level, PlaceOS::Api::LOG_BACKEND
config.bind "action-controller.*", log_level, PlaceOS::Api::LOG_BACKEND
config.bind "rest-api.*", log_level, PlaceOS::Api::LOG_BACKEND
# Bind raven's backend
config.bind "rest-api.*", :info, Raven::LogBackend.new
config.bind "rest-api.*", :warn, Raven::LogBackend.new(capture_all: true)
config.bind "place_os.*", :info, Raven::LogBackend.new
config.bind "place_os.*", :warn, Raven::LogBackend.new(capture_all: true)
end

# Application code
require "./placeos-rest-api"

# Server required after application controllers
require "action-controller/server"

# Configure Sentry
Raven.configure do |config|
config.async = true
end

# Configure Service discovery
HoundDog.configure do |settings|
settings.etcd_host = PlaceOS::Api::ETCD_HOST
Expand Down
1 change: 1 addition & 0 deletions src/placeos-rest-api/controllers/application.cr
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module PlaceOS::Api
client_ip: client_ip,
request_id: request_id
)

response.headers["X-Request-ID"] = request_id
end

Expand Down

0 comments on commit 48dddec

Please sign in to comment.