Class: Loggr::FluentEvent
- Inherits:
-
Object
- Object
- Loggr::FluentEvent
- Defined in:
- lib/loggr-rb/events.rb
Instance Method Summary collapse
- #add_data(text) ⇒ Object
- #add_dataf(fmt, *args) ⇒ Object
- #add_tags(tags) ⇒ Object
- #add_text(text) ⇒ Object
- #add_textf(fmt, *args) ⇒ Object
- #assign_w_macros(input, base) ⇒ Object
- #data(text) ⇒ Object
- #dataf(fmt, *args) ⇒ Object
- #datatype(t) ⇒ Object
- #geo(lat, lon) ⇒ Object
- #geo_clear ⇒ Object
- #geo_ip(ip) ⇒ Object
-
#initialize(callback = nil) ⇒ FluentEvent
constructor
A new instance of FluentEvent.
- #link(text) ⇒ Object
- #linkf(fmt, *args) ⇒ Object
- #post(async = true) ⇒ Object
- #source(text) ⇒ Object
- #sourcef(fmt, *args) ⇒ Object
- #tags(tags) ⇒ Object
- #text(text) ⇒ Object
- #textf(fmt, *args) ⇒ Object
- #user(text) ⇒ Object
- #userf(fmt, *args) ⇒ Object
- #value(val) ⇒ Object
- #value_clear ⇒ Object
Constructor Details
#initialize(callback = nil) ⇒ FluentEvent
Returns a new instance of FluentEvent.
52 53 54 55 |
# File 'lib/loggr-rb/events.rb', line 52 def initialize(callback=nil) @callback = callback @event = Event.new() end |
Instance Method Details
#add_data(text) ⇒ Object
120 121 122 123 |
# File 'lib/loggr-rb/events.rb', line 120 def add_data(text) @event.data = sprintf("%s%s", @event.data, text) return self end |
#add_dataf(fmt, *args) ⇒ Object
125 126 127 128 |
# File 'lib/loggr-rb/events.rb', line 125 def add_dataf(fmt, *args) self.add_data(sprintf(fmt, args)) return self end |
#add_tags(tags) ⇒ Object
145 146 147 148 |
# File 'lib/loggr-rb/events.rb', line 145 def () @event. = sprintf("%s %s", @event., ) return self end |
#add_text(text) ⇒ Object
74 75 76 77 |
# File 'lib/loggr-rb/events.rb', line 74 def add_text(text) @event.text = sprintf("%s%s", @event.text, text) return self end |
#add_textf(fmt, *args) ⇒ Object
79 80 81 82 |
# File 'lib/loggr-rb/events.rb', line 79 def add_textf(fmt, *args) self.add_text(sprintf(fmt, args)) return self end |
#assign_w_macros(input, base) ⇒ Object
170 171 172 173 174 175 |
# File 'lib/loggr-rb/events.rb', line 170 def assign_w_macros(input, base) if base.nil? base = "" end return input.gsub("$$", base) end |
#data(text) ⇒ Object
111 112 113 114 |
# File 'lib/loggr-rb/events.rb', line 111 def data(text) @event.data = self.assign_w_macros(text, @event.data) return self end |
#dataf(fmt, *args) ⇒ Object
116 117 118 |
# File 'lib/loggr-rb/events.rb', line 116 def dataf(fmt, *args) self.data(sprintf(fmt, args)) end |
#datatype(t) ⇒ Object
150 151 152 153 |
# File 'lib/loggr-rb/events.rb', line 150 def datatype(t) @event.datatype = t return self end |
#geo(lat, lon) ⇒ Object
155 156 157 158 |
# File 'lib/loggr-rb/events.rb', line 155 def geo(lat, lon) @event.geo = sprintf("%d,%d", lat, lon) return self end |
#geo_clear ⇒ Object
165 166 167 168 |
# File 'lib/loggr-rb/events.rb', line 165 def geo_clear() @event.geo = nil return self end |
#geo_ip(ip) ⇒ Object
160 161 162 163 |
# File 'lib/loggr-rb/events.rb', line 160 def geo_ip(ip) @event.geo = sprintf("ip:%s", ip) return self end |
#link(text) ⇒ Object
102 103 104 105 |
# File 'lib/loggr-rb/events.rb', line 102 def link(text) @event.link = self.assign_w_macros(text, @event.link) return self end |
#linkf(fmt, *args) ⇒ Object
107 108 109 |
# File 'lib/loggr-rb/events.rb', line 107 def linkf(fmt, *args) self.link(sprintf(fmt, args)) end |
#post(async = true) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/loggr-rb/events.rb', line 57 def post(async=true) if !@callback.nil? @callback.call(self) end LogClient.post(@event,async) end |
#source(text) ⇒ Object
84 85 86 87 |
# File 'lib/loggr-rb/events.rb', line 84 def source(text) @event.source = self.assign_w_macros(text, @event.source) return self end |
#sourcef(fmt, *args) ⇒ Object
89 90 91 |
# File 'lib/loggr-rb/events.rb', line 89 def sourcef(fmt, *args) self.source(sprintf(fmt, args)) end |
#tags(tags) ⇒ Object
140 141 142 143 |
# File 'lib/loggr-rb/events.rb', line 140 def () @event. = return self end |
#text(text) ⇒ Object
64 65 66 67 |
# File 'lib/loggr-rb/events.rb', line 64 def text(text) @event.text = self.assign_w_macros(text, @event.text) return self end |
#textf(fmt, *args) ⇒ Object
69 70 71 72 |
# File 'lib/loggr-rb/events.rb', line 69 def textf(fmt, *args) self.text(sprintf(fmt, args)) return self end |
#user(text) ⇒ Object
93 94 95 96 |
# File 'lib/loggr-rb/events.rb', line 93 def user(text) @event.user = self.assign_w_macros(text, @event.user) return self end |
#userf(fmt, *args) ⇒ Object
98 99 100 |
# File 'lib/loggr-rb/events.rb', line 98 def userf(fmt, *args) self.user(sprintf(fmt, args)) end |
#value(val) ⇒ Object
130 131 132 133 |
# File 'lib/loggr-rb/events.rb', line 130 def value(val) @event.value = val return self end |
#value_clear ⇒ Object
135 136 137 138 |
# File 'lib/loggr-rb/events.rb', line 135 def value_clear() @event.value = nil return self end |