Class: Fluent::GrowlOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::GrowlOutput
- Defined in:
- lib/fluent/plugin/out_growl.rb
Constant Summary collapse
- DEFAULT_SERVER =
"localhost"
- DEFAULT_PASSWORD =
nil
- DEFAULT_APPNAME =
"Fluent Growl Notification"
- DEFAULT_NOTIFICATION_NAME =
"Fluent Defalt Notification"
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ GrowlOutput
constructor
A new instance of GrowlOutput.
Constructor Details
#initialize ⇒ GrowlOutput
Returns a new instance of GrowlOutput.
15 16 17 |
# File 'lib/fluent/plugin/out_growl.rb', line 15 def initialize @growl end |
Instance Method Details
#configure(conf) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fluent/plugin/out_growl.rb', line 19 def configure(conf) server = conf['server'] || DEFAULT_SERVER password = conf['password'] || DEFAULT_PASSWORD appname = conf['appname'] || DEFAULT_APPNAME @notifies = {} conf.elements.select{|e| e.name = "notify" }.each{|e| name = e['name'] unless name raise ConfigError, "Missing 'name' parameter on <notify> directive" end priority = e['priority'].to_i sticky = (e.has_key? "sticky") && (e["sticky"].match /y(es)?|on|true/i ) && true @notifies[name] = {:priority => priority, :sticky => sticky} } # if @notifies.empty? # raise ConfigError, "At least one <notify> directive is needed" # end @notifies[DEFAULT_NOTIFICATION_NAME] = {:priority => 0, :sticky => false} @growl = Growl.new server, appname, @notifies.keys, nil, password end |
#emit(tag, es, chain) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fluent/plugin/out_growl.rb', line 44 def emit(tag, es, chain) es.each{|e| title = e.record["title"] || "Fluent Notification" = e.record["message"] || "#{e.record.to_json} at #{Time.at(e.time).localtime}" notifyname = e.record["notify"] || DEFAULT_NOTIFICATION_NAME notify = @notifies[notifyname] unless notify # TODO: ConfigError? raise ConfigError, "Unknown notify name '#{notifyname}'" end @growl.notify notifyname, title, , notify[:priority], notify[:sticky] } chain.next end |