Class: Binnacle::Event
- Defined in:
- lib/binnacle/resources/event.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#channel_id ⇒ Object
Returns the value of attribute channel_id.
-
#client_event_time ⇒ Object
Returns the value of attribute client_event_time.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#event_name ⇒ Object
Returns the value of attribute event_name.
-
#event_time ⇒ Object
Returns the value of attribute event_time.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#json ⇒ Object
Returns the value of attribute json.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#tags ⇒ Object
Returns the value of attribute tags.
Attributes inherited from Resource
Class Method Summary collapse
- .events(connection, channel, date, start_hour, end_hour, lines, environment = rails_env) ⇒ Object
- .from_hash(h) ⇒ Object
- .recents(connection, lines, since, channel, environment = rails_env) ⇒ Object
- .route(channel) ⇒ Object
Instance Method Summary collapse
- #configure(channel_id, event_name, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, tags = [], json = {}) ⇒ Object
- #configure_from_logging_progname(progname, channel_id, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, tags = [], json = {}) ⇒ Object
- #route ⇒ Object
- #timestamp=(ts) ⇒ Object
- #to_json ⇒ Object
Methods inherited from Resource
Instance Attribute Details
#channel_id ⇒ Object
Returns the value of attribute channel_id.
4 5 6 |
# File 'lib/binnacle/resources/event.rb', line 4 def channel_id @channel_id end |
#client_event_time ⇒ Object
Returns the value of attribute client_event_time.
8 9 10 |
# File 'lib/binnacle/resources/event.rb', line 8 def client_event_time @client_event_time end |
#client_id ⇒ Object
Returns the value of attribute client_id.
6 7 8 |
# File 'lib/binnacle/resources/event.rb', line 6 def client_id @client_id end |
#environment ⇒ Object
Returns the value of attribute environment.
14 15 16 |
# File 'lib/binnacle/resources/event.rb', line 14 def environment @environment end |
#event_name ⇒ Object
Returns the value of attribute event_name.
5 6 7 |
# File 'lib/binnacle/resources/event.rb', line 5 def event_name @event_name end |
#event_time ⇒ Object
Returns the value of attribute event_time.
13 14 15 |
# File 'lib/binnacle/resources/event.rb', line 13 def event_time @event_time end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
9 10 11 |
# File 'lib/binnacle/resources/event.rb', line 9 def ip_address @ip_address end |
#json ⇒ Object
Returns the value of attribute json.
12 13 14 |
# File 'lib/binnacle/resources/event.rb', line 12 def json @json end |
#log_level ⇒ Object
Returns the value of attribute log_level.
10 11 12 |
# File 'lib/binnacle/resources/event.rb', line 10 def log_level @log_level end |
#session_id ⇒ Object
Returns the value of attribute session_id.
7 8 9 |
# File 'lib/binnacle/resources/event.rb', line 7 def session_id @session_id end |
#tags ⇒ Object
Returns the value of attribute tags.
11 12 13 |
# File 'lib/binnacle/resources/event.rb', line 11 def @tags end |
Class Method Details
.events(connection, channel, date, start_hour, end_hour, lines, environment = rails_env) ⇒ Object
101 102 103 104 105 |
# File 'lib/binnacle/resources/event.rb', line 101 def self.events(connection, channel, date, start_hour, end_hour, lines, environment = rails_env) path = [route(channel), environment, date].compact.join('/') get(connection, path, {'start_hour' => start_hour, 'end_hour' => end_hour, 'limit' => lines}) end |
.from_hash(h) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/binnacle/resources/event.rb', line 57 def self.from_hash(h) event = self.new() event.channel_id = h['channelId'] event.event_name = h['eventName'] event.client_id = h['clientId'] event.session_id = h['sessionId'] event.ip_address = h['ipAddress'] event.log_level = h['logLevel'] event.event_time = Time.at(h['eventTime']/1000) event. = h['tags'] event.json = h['json'] event.environment = h['environment'] event end |
.recents(connection, lines, since, channel, environment = rails_env) ⇒ Object
95 96 97 98 99 |
# File 'lib/binnacle/resources/event.rb', line 95 def self.recents(connection, lines, since, channel, environment = rails_env) path = [route(channel), environment, 'recents'].compact.join('/') get(connection, path, {'limit' => lines, 'since' => since}) end |
.route(channel) ⇒ Object
91 92 93 |
# File 'lib/binnacle/resources/event.rb', line 91 def self.route(channel) "/api/events/#{channel}" end |
Instance Method Details
#configure(channel_id, event_name, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, tags = [], json = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/binnacle/resources/event.rb', line 16 def configure(channel_id, event_name, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, = [], json = {}) self.channel_id = channel_id self.event_name = event_name self.client_id = client_id self.session_id = session_id self. = ts ? ts : Time.now self.log_level = log_level self. = self.json = json self.environment = environment || Event.rails_env end |
#configure_from_logging_progname(progname, channel_id, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, tags = [], json = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/binnacle/resources/event.rb', line 28 def configure_from_logging_progname(progname, channel_id, client_id, session_id, log_level, environment = Event.rails_env, ts = Time.now, = [], json = {}) if progname.is_a?(Hash) self.client_id = progname[:client_id] || client_id self.session_id = progname[:session_id] || session_id self.channel_id = progname[:channel_id] || channel_id self.event_name = progname[:event_name] self. = progname[:tags] || self.json = json self.json.merge!(progname[:json]) if progname[:json] self.environment = environment || Event.rails_env elsif progname.is_a?(String) self.client_id = client_id self.session_id = session_id self.channel_id = channel_id self.event_name = progname self. = self.json = json self.environment = environment || Event.rails_env end self. = ts ? ts : Time.now self.log_level = log_level self.environment = environment || Event.rails_env end |
#route ⇒ Object
87 88 89 |
# File 'lib/binnacle/resources/event.rb', line 87 def route "/api/events/#{channel_id}" end |
#timestamp=(ts) ⇒ Object
53 54 55 |
# File 'lib/binnacle/resources/event.rb', line 53 def (ts) self.client_event_time = ts.strftime("%Y-%m-%dT%H:%M:%S%z") end |
#to_json ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/binnacle/resources/event.rb', line 73 def to_json { "channelId" => channel_id, "sessionId" => session_id, "clientEventTime" => client_event_time, "eventName" => event_name, "clientId" => client_id, "logLevel" => log_level, "tags" => , "environment" => environment, "json" => json }.to_json end |