Class: Loggr::FluentEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/loggr-rb/events.rb

Instance Method Summary collapse

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 add_tags(tags)
  @event.tags = sprintf("%s %s", @event.tags, tags)
  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_clearObject



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


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 tags(tags)
  @event.tags = tags
  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_clearObject



135
136
137
138
# File 'lib/loggr-rb/events.rb', line 135

def value_clear()
  @event.value = nil
  return self
end