Class: Amalgalite::Taps::IO
- Inherits:
-
Object
- Object
- Amalgalite::Taps::IO
- Defined in:
- lib/amalgalite/taps/io.rb
Overview
An IOTap is an easy way to send all top information to any IO based object. Both profile and trace tap information can be captured This means you can send the events to STDOUT with:
db.profile_tap = db.trace_tap = Amalgalite::Taps::Stdout.new
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#profile_tap ⇒ Object
readonly
Returns the value of attribute profile_tap.
-
#trace_count ⇒ Object
readonly
Returns the value of attribute trace_count.
Instance Method Summary collapse
- #dump_profile ⇒ Object
-
#initialize(io) ⇒ IO
constructor
A new instance of IO.
- #output_profile_event(msg, time) ⇒ Object
-
#profile(msg, time) ⇒ Object
need a profile method, it routes through the profile tap which calls back to output_profile_event.
- #samplers ⇒ Object
- #trace(msg) ⇒ Object
Constructor Details
#initialize(io) ⇒ IO
Returns a new instance of IO.
25 26 27 28 29 |
# File 'lib/amalgalite/taps/io.rb', line 25 def initialize( io ) @io = io @profile_tap = ProfileTap.new( self, 'output_profile_event' ) @trace_count = 0 end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
22 23 24 |
# File 'lib/amalgalite/taps/io.rb', line 22 def io @io end |
#profile_tap ⇒ Object (readonly)
Returns the value of attribute profile_tap.
21 22 23 |
# File 'lib/amalgalite/taps/io.rb', line 21 def profile_tap @profile_tap end |
#trace_count ⇒ Object (readonly)
Returns the value of attribute trace_count.
23 24 25 |
# File 'lib/amalgalite/taps/io.rb', line 23 def trace_count @trace_count end |
Instance Method Details
#dump_profile ⇒ Object
46 47 48 49 50 |
# File 'lib/amalgalite/taps/io.rb', line 46 def dump_profile samplers.each_pair do |k,v| io.puts v.to_s end end |
#output_profile_event(msg, time) ⇒ Object
42 43 44 |
# File 'lib/amalgalite/taps/io.rb', line 42 def output_profile_event( msg, time ) io.puts "#{time} : #{msg}" end |
#profile(msg, time) ⇒ Object
need a profile method, it routes through the profile tap which calls back to output_profile_event
38 39 40 |
# File 'lib/amalgalite/taps/io.rb', line 38 def profile( msg, time ) @profile_tap.profile(msg, time) end |
#samplers ⇒ Object
52 53 54 |
# File 'lib/amalgalite/taps/io.rb', line 52 def samplers profile_tap.samplers end |
#trace(msg) ⇒ Object
31 32 33 34 |
# File 'lib/amalgalite/taps/io.rb', line 31 def trace( msg ) @trace_count += 1 io.puts msg end |