Class: Logging::Appenders::Growl
- Inherits:
-
Logging::Appender
- Object
- Logging::Appender
- Logging::Appenders::Growl
- Defined in:
- lib/logging/appenders/growl.rb
Overview
This class provides an Appender that can send notifications to the Growl notification system on Mac OS X.
growlnotify
must be installed somewhere in the path in order for the appender to function properly.
Constant Summary collapse
- ColoredRegexp =
:stopdoc:
%r/\e\[([34][0-7]|[0-9])m/
Instance Attribute Summary
Attributes inherited from Logging::Appender
Instance Method Summary collapse
-
#initialize(name, opts = {}) ⇒ Growl
constructor
call-seq: Growl.new( name, opts = {} ).
-
#map=(levels) ⇒ Object
call-seq: map = { logging_levels => growl_levels }.
Methods inherited from Logging::Appender
#<<, #append, #close, #closed?, #flush, #inspect, #reopen
Constructor Details
#initialize(name, opts = {}) ⇒ Growl
call-seq:
Growl.new( name, opts = {} )
Create an appender that will log messages to the Growl framework on a Mac OS X machine.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/logging/appenders/growl.rb', line 22 def initialize( name, opts = {} ) super @growl = "growlnotify -w -n \"#{@name}\" -t \"%s\" -m \"%s\" -p %d &" @coalesce = opts.getopt(:coalesce, false) @title_sep = opts.getopt(:separator) # provides a mapping from the default Logging levels # to the Growl notification levels @map = [-2, -1, 0, 1, 2] map = opts.getopt(:map) self.map = map unless map.nil? setup_coalescing if @coalesce # make sure the growlnotify command can be called unless system('growlnotify -v >> /dev/null 2>&1') self.level = :off ::Logging.log_internal {'growl notifications have been disabled'} end end |
Instance Method Details
#map=(levels) ⇒ Object
call-seq:
map = { logging_levels => growl_levels }
Configure the mapping from the Logging levels to the Growl notification levels. This is needed in order to log events at the proper Growl level.
Without any configuration, the following mapping will be used:
:debug => -2
:info => -1
:warn => 0
:error => 1
:fatal => 2
60 61 62 63 64 65 66 67 |
# File 'lib/logging/appenders/growl.rb', line 60 def map=( levels ) map = [] levels.keys.each do |lvl| num = ::Logging.level_num(lvl) map[num] = growl_level_num(levels[lvl]) end @map = map end |