Class: BlackDog::LogFile

Inherits:
Object
  • Object
show all
Defined in:
lib/blackdog/blackdog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ LogFile



72
73
74
75
# File 'lib/blackdog/blackdog.rb', line 72

def initialize(path)
  @path = path
  @watches = []
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



70
71
72
# File 'lib/blackdog/blackdog.rb', line 70

def path
  @path
end

#watchesObject (readonly)

Returns the value of attribute watches.



70
71
72
# File 'lib/blackdog/blackdog.rb', line 70

def watches
  @watches
end

Instance Method Details

#each_watchObject



99
100
101
# File 'lib/blackdog/blackdog.rb', line 99

def each_watch
  @watches.each {|w| yield w }
end

#watch {|w = Watch.new| ... } ⇒ Object

Yields:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/blackdog/blackdog.rb', line 77

def watch
  yield w = Watch.new
  @watches << w

  # {{{ logging
  if w.throttle
    BlackDog.log.debug(@path) {
      "watching for #{w.pattern.inspect} with throttle \
#{w.throttle[:times]}/#{w.throttle[:every]} secs"
    }
  else
    BlackDog.log.debug(@path) { "watching for #{w.pattern.inspect}" }

    if w.throttle == false
      BlackDog.log.warn(@path) {
        "ignoring invalid throttle for watch #{w.pattern.inspect}"
      }
    end
  end
  # }}}
end