Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed some loose ends

  • Loading branch information...
commit 06bd67ed3c2c317990952369608e0a5810504d88 1 parent 031f9b5
@mathieuravaux authored
Showing with 18 additions and 6 deletions.
  1. +1 −0  .gitignore
  2. +11 −0 Rakefile
  3. +6 −6 lib/brm-ruby-logger.rb
View
1  .gitignore
@@ -17,5 +17,6 @@ tmtags
coverage
rdoc
pkg
+tmp
## PROJECT::SPECIFIC
View
11 Rakefile
@@ -2,6 +2,17 @@ require 'rubygems'
require 'rake'
begin
+ require 'metric_fu' rescue LoadError
+ MetricFu::Configuration.run do |config|
+ config.metrics = [:flog, :flay, :reek, :saikuro]
+ config.graphs = [:flog, :flay, :reek]
+ config.graph_engine = :gchart
+ end
+rescue LoadError
+ puts "Metric_fu (or a dependency) not available. Install it with: gem install metric_fu"
+end
+
+begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "brm-ruby-logger"
View
12 lib/brm-ruby-logger.rb
@@ -3,7 +3,7 @@
require "rubygems"
require "bunny"
require "active_support"
-require "pp"
+require "json"
require "logger/event.rb"
@@ -25,16 +25,17 @@ def initialize(user_id, application, *args)
bunny_options = args.extract_options!
@connection = Bunny.new bunny_options
@connection.start
+ @queue = @connection.queue "/"
end
def disconnect()
@connection.stop
end
- def event(eventName, data=nil, context=nil, event_ref="")
+ def event(event_name, data=nil, context=nil, event_ref="")
event = HashWithIndifferentAccess.new
event["data"] = data || {}
- event["context"] = context || {}
+ event["context"] ||= {}
event["data"]["agent"] = {:id => facet_id, :type => "facet"} if facet_id
@@ -43,10 +44,9 @@ def event(eventName, data=nil, context=nil, event_ref="")
event["data"]["agent"] ||= {:id => user_id, :type => "user"}
event["context"]["userID"] = user_id
end
-
event["metaData"] = {
"timestamp" => Time.now.to_i * 1000,
- "eventName" => $eventName,
+ "eventName" => event_name,
"application" => application,
"loggerVersion" => VERSION,
"loggerType" => "ruby",
@@ -62,7 +62,7 @@ def event(eventName, data=nil, context=nil, event_ref="")
private
def send event
-
+ @queue.publish event.to_json
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.