Class: GrowlLogger::LogDevice
- Inherits:
-
Object
- Object
- GrowlLogger::LogDevice
- Defined in:
- lib/growl-logger.rb
Instance Method Summary collapse
- #close ⇒ Object
- #get_priority(message) ⇒ Object
-
#initialize(name, growlnotify_mode = true, &block) ⇒ LogDevice
constructor
A new instance of LogDevice.
- #write(message) ⇒ Object
Constructor Details
#initialize(name, growlnotify_mode = true, &block) ⇒ LogDevice
Returns a new instance of LogDevice.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/growl-logger.rb', line 19 def initialize(name, growlnotify_mode = true, &block) @name = name @growlnotify_mode = growlnotify_mode unless @growlnotify_mode begin require 'ruby-growl' @growl = Growl.new "localhost", @name, ["log"] rescue LoadError end end @formatter = block if block_given? end |
Instance Method Details
#close ⇒ Object
58 |
# File 'lib/growl-logger.rb', line 58 def close;end |
#get_priority(message) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/growl-logger.rb', line 41 def get_priority() case when /^DEBUG/ -2 when /^INFO/ -1 when /^WARN/ 0 when /^ERROR/ 1 when /^FATAL/ 2 else 0 end end |
#write(message) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/growl-logger.rb', line 32 def write() priority = get_priority() if @growl @growl.notify "log", @name, , priority else system 'growlnotify', @name, '-p', priority.to_s, '-m', end end |