Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

changes

  • Loading branch information...
commit 60487cc2182dd3f0fbc841d7f45afc61ef18ffc5 1 parent 2b8efe7
Tom Preston-Werner mojombo authored
20 lib/god/logger.rb
@@ -56,22 +56,22 @@ def load_syslog
56 56 # Returns nothing
57 57 def log(watch, level, text)
58 58 # initialize watch log if necessary
59   - self.logs[watch.name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT) if watch
  59 + # self.logs[watch.name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT) if watch
60 60
61 61 # push onto capture and timeline for the given watch
62   - @templogio.truncate(0)
63   - @templogio.rewind
64   - @templog.send(level, text % [])
65   - @mutex.synchronize do
66   - @capture.puts(@templogio.string) if @capture
67   - self.logs[watch.name] << [] if watch # [Time.now, @templogio.string] if watch
68   - end
  62 + # @templogio.truncate(0)
  63 + # @templogio.rewind
  64 + # @templog.send(level, text % [])
  65 + # @mutex.synchronize do
  66 + # @capture.puts(@templogio.string) if @capture
  67 + # self.logs[watch.name] << '' if watch # [Time.now, @templogio.string] if watch
  68 + # end
69 69
70 70 # send to regular logger
71   - self.send(level, text % [])
  71 + # self.send(level, text % [])
72 72
73 73 # send to syslog
74   - Syslog.send(SYSLOG_EQUIVALENTS[level], text) if Logger.syslog
  74 + # Syslog.send(SYSLOG_EQUIVALENTS[level], text) if Logger.syslog
75 75 end
76 76
77 77 # Get all log output for a given Watch since a certain Time.
24 lib/god/timeline.rb
... ... @@ -1,6 +1,9 @@
1 1 module God
2 2
3 3 class Timeline
  4 + extend Forwardable
  5 + def_delegators :@storage, :clear, :size, :first, :last, :[], :to_ary, :to_a
  6 +
4 7 # Instantiate a new Timeline
5 8 # +max_size+ is the maximum size to which the timeline should grow
6 9 #
@@ -13,17 +16,20 @@ def initialize(max_size)
13 16 # Push a value onto the Timeline
14 17 # +val+ is the value to push
15 18 def push(val)
16   - @storage.concat(val)
17   - @storage.shift if @storage.size > @max_size
  19 + @storage.concat([val])
  20 + @storage = @storage[1..-1] if @storage.size > @max_size
  21 + # @storage.shift if @storage.size > @max_size
18 22 end
19 23
20   - # Push a value onto the timeline
21   - # +val+ is the value to push
22   - #
23   - # Returns Timeline
24   - def <<(val)
25   - push(val)
26   - end
  24 + alias_method :<<, :push
  25 +
  26 + # # Push a value onto the timeline
  27 + # # +val+ is the value to push
  28 + # #
  29 + # # Returns Timeline
  30 + # def <<(val)
  31 + # push(val)
  32 + # end
27 33 end
28 34
29 35 end
2  test/test_timeline.rb
@@ -14,7 +14,7 @@ def test_should_not_grow_to_more_than_size
14 14 @timeline.push(i)
15 15 end
16 16
17   - assert_equal [6, 7, 8, 9, 10], @timeline
  17 + assert_equal [6, 7, 8, 9, 10], @timeline.to_ary
18 18 end
19 19
20 20 def test_clear_should_clear_array

0 comments on commit 60487cc

Please sign in to comment.
Something went wrong with that request. Please try again.