Accessing Overseer and send easily exceptions for your application
Just in console
gem install overseer-api
Or put into Gemfile
gem "overseer-api"
#or
gem "overseer-api", :git => "git://github.com/Ataxo/overseer-api.git"
and somewhere before use (not rails - they will require gem automaticaly)
require "overseer-api"
Setup your config values
- Rails - put it into config/initializers/overseer.rb
- Sinatra - somewher in initialization
OverseerApi.app_name = "Your app name"
#optional settings
OverseerApi.version = :v1
#default is :v1
#url where is slim api located
OverseerApi.url = "http://overseer.ataxo.com"
When some exception came, you can log it by calling method:
OverseerApi.send_exception TYPE, EXECEPTION, ARGUMENTS, TAGS, RAISED_AT
TYPE = [:error, :warn, :info]
EXCEPTION = subclass of Exception
ARGUMENTS = nil, array or hash
TAGS = custom text (can be splitted by comma)
RAISED_AT = Time when exceptin been raised
example:
args = {foo: "bar"}
begin
raise ArgumentError, "Some message"
rescue Exception => e
OverseerApi.log :error, e, args, "my bad error"
end
#or by type:
begin
raise ArgumentError, "Some message"
rescue Exception => e
OverseerApi.error e, args
#optionaly
OverseerApi.log e, args
OverseerApi.info e, args
OverseerApi.warn e, args
end
if you don't rescuing from begin/rescue block and you want to send log to Overseer you can use:
#string as name of error
OverseerApi.info "MyCustomClass", {foo:"bar"}
#or use hash with custom message and backtrace
OverseerApi.info {klass: "MyCustomClass", message: "My message"}, {foo:"bar"}
You need to use resque-scheduler
and in your schedule.yml
add lines:
send_failed_to_overseer:
cron: "*/10 * * * *"
class: OverseerApi
queue: overseer #change this by your own application specific workers
#ensure that at least one worker is working on this queue
description: "Send failed jobs to Overseer"
Copyright (c) 2012 Ondrej Bartas. See LICENSE.txt for further details.