Skip to content
Browse files

Timeline#messages

  • Loading branch information...
1 parent da102ad commit c8b0c2a213820d9215d93b8ab140c33f96e3c0a2 @delano committed Nov 2, 2009
Showing with 29 additions and 5 deletions.
  1. +2 −0 CHANGES.txt
  2. +2 −1 lib/benelux.rb
  3. +25 −4 lib/benelux/timeline.rb
View
2 CHANGES.txt
@@ -6,6 +6,8 @@ BENELUX, CHANGES
* ADDED: Thread#rotate_timeline
* ADDED: Stats#clear
* ADDED: Selectable#rfilter
+* ADDED: Timeline#messages
+
#### 0.5.0 (2009-10-21) ###############################
View
3 lib/benelux.rb
@@ -76,7 +76,8 @@ def Benelux.current_track(name=nil,group=nil)
end
Benelux.current_track :main
- # Only updates data from threads that are dead
+ # Only updates data from threads that
+ # are dead and rotated timelines.
def Benelux.update_global_timeline
@@mutex.synchronize do
dthreads = Benelux.known_threads.select { |t|
View
29 lib/benelux/timeline.rb
@@ -21,13 +21,15 @@ class Timeline < Array
include Selectable
attr_accessor :ranges
attr_accessor :stats
+ attr_accessor :messages
attr_accessor :default_tags
attr_reader :caller
def initialize(*args)
@caller = Kernel.caller
@ranges = SelectableArray.new
@default_tags = Selectable::Tags.new
@stats = Benelux::Stats.new
+ @messages = SelectableArray.new
add_default_tag :thread_id => Thread.current.object_id.abs
super
end
@@ -81,6 +83,7 @@ def [](*tags)
next unless stat.tags >= tags
stats += stat
end
+ tl.messages = messages
tl.stats = stats
tl
end
@@ -121,12 +124,28 @@ def regions(name=nil, tags=Selectable::Tags.new)
end
end
+ def messages(tags=Selectable::Tags.new)
+ ret = @messages.select do |msg|
+ (tags.nil? || msg.tags >= tags)
+ end
+ SelectableArray.new ret
+ end
+
def clear
@ranges.clear
@stats.clear
+ @messages.clear
super
end
+ def add_message(str, tags={})
+ msg = TaggableString.new str
+ msg.add_tags self.default_tags
+ msg.add_tags tags
+ @messages << msg
+ msg
+ end
+
def add_count(name, count, tags={})
tags = tags.merge self.default_tags
self.stats.add_group(name)
@@ -155,16 +174,18 @@ def add_range(name, from, to)
def merge!(*timelines)
timelines.each do |tl|
self.push *tl
- self.ranges.push *tl.ranges
- self.stats += tl.stats
+ @ranges.push *tl.ranges
+ @messages.push *tl.messages
+ @stats += tl.stats
end
self
end
def +(other)
self.push *other
- self.ranges.push *other.ranges
- self.stats += other.stats
+ @ranges.push *other.ranges
+ @messages.push *tl.messages
+ @stats += other.stats
self
end
# Needs to compare thread id and call id.

0 comments on commit c8b0c2a

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