3 class Logger < ::Logger
4 SYSLOG_EQUIVALENTS = {:fatal => :crit,
21 @capture = StringIO.new
33 def log(watch, level, text)
34 # initialize watch log if necessary
35 self.logs[watch.name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT) if watch
37 # push onto capture and timeline for the given watch
39 templog = ::Logger.new(buf)
40 templog.level = Logger::INFO
41 templog.send(level, text)
43 @capture.puts(buf.string) if @capture
44 self.logs[watch.name] << [Time.now, buf.string] if watch
48 # send to regular logger
49 self.send(level, text)
52 Syslog.send(SYSLOG_EQUIVALENTS[level], text)
55 def watch_log_since(watch_name, since)
56 # initialize watch log if necessary
57 self.logs[watch_name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT)
59 # get and join lines since given time
61 self.logs[watch_name].select do |x|