class SentinelApi::Notifier
Public Class Methods
error(*args)
click to toggle source
# File lib/sentinel_api/notifier.rb, line 15 def error(*args) log('ERROR', args) end
info(*args)
click to toggle source
# File lib/sentinel_api/notifier.rb, line 11 def info(*args) log('INFO', args) end
warn(*args)
click to toggle source
# File lib/sentinel_api/notifier.rb, line 7 def warn(*args) log('WARN', args) end
Private Class Methods
configuration()
click to toggle source
# File lib/sentinel_api/notifier.rb, line 63 def configuration SentinelApi.configuration end
extract_arguments(args)
click to toggle source
# File lib/sentinel_api/notifier.rb, line 29 def extract_arguments(args) message = nil exception = nil tags = nil if args.count == 1 && args[0].is_a?(Hash) result = args[0].with_indifferent_access return [result[:message], result[:info], result[:tags]] elsif args.count == 1 && args[0].is_a?(Exception) return [args[0].message, prepare_info(args[0]), []] else args.each do |arg| if arg.is_a?(String) message = arg elsif arg.is_a?(Exception) exception = arg elsif RUBY_PLATFORM == 'java' && arg.is_a?(java.lang.Exception) exception = arg elsif arg.is_a?(Array) tags = arg tags = nil if tags.empty? end end end [message, prepare_info(exception), tags] end
log(level = nil, args)
click to toggle source
# File lib/sentinel_api/notifier.rb, line 21 def log(level = nil, args) level ||= configuration.level project_name ||= configuration.project_name message, info, tags = extract_arguments(args) SentinelApi::Client.send_to_server({ level: level, message: message, info: info, tags: tags, project_name: project_name }) end
prepare_info(exception)
click to toggle source
# File lib/sentinel_api/notifier.rb, line 57 def prepare_info(exception) "#{exception.class}: #{exception.message}, \n#{exception.backtrace.join("\n")}" rescue "#{exception.class}: #{exception.message}" end