Module: Butler::DebugLog

Defined in:
lib/butler/debuglog.rb

Overview

Extend an object with debug-log and it will print all read/write actions to @raw_log (defaulting to $stderr)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#raw_logObject

The object to call printf on to log read/writes.



11
12
13
# File 'lib/butler/debuglog.rb', line 11

def raw_log
  @raw_log
end

Class Method Details

.extended(obj) ⇒ Object

:nodoc:



6
7
8
# File 'lib/butler/debuglog.rb', line 6

def self.extended(obj) # :nodoc:
	obj.raw_log = $stderr
end

Instance Method Details

#readObject

:nodoc:



13
14
15
16
17
# File 'lib/butler/debuglog.rb', line 13

def read # :nodoc:
	data = super
	@raw_log.printf("<- %s %p\n", Time.now, data)
	data
end

#write(data) ⇒ Object

:nodoc:



19
20
21
22
23
# File 'lib/butler/debuglog.rb', line 19

def write(data) # :nodoc:
	rv = super
	@raw_log.printf("-> %s %p\n", Time.now, data)
	rv
end