Class: ChupaText::CaptureLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/chupa-text/capture-logger.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ CaptureLogger

Returns a new instance of CaptureLogger.



33
34
35
# File 'lib/chupa-text/capture-logger.rb', line 33

def initialize(output)
  @output = output
end

Class Method Details

.captureObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chupa-text/capture-logger.rb', line 20

def capture
  original_logger = ChupaText.logger
  begin
    output = []
    ChupaText.logger = new(output)
    yield
    output
  ensure
    ChupaText.logger = original_logger
  end
end

Instance Method Details

#debug(message = nil) ⇒ Object



37
38
39
# File 'lib/chupa-text/capture-logger.rb', line 37

def debug(message=nil)
  @output << [:debu, message || yield]
end

#error(message = nil) ⇒ Object



49
50
51
# File 'lib/chupa-text/capture-logger.rb', line 49

def error(message=nil)
  @output << [:error, message || yield]
end

#fatal(message = nil) ⇒ Object



53
54
55
# File 'lib/chupa-text/capture-logger.rb', line 53

def fatal(message=nil)
  @output << [:fatal, message || yield]
end

#info(message = nil) ⇒ Object



41
42
43
# File 'lib/chupa-text/capture-logger.rb', line 41

def info(message=nil)
  @output << [:info, message || yield]
end

#warn(message = nil) ⇒ Object



45
46
47
# File 'lib/chupa-text/capture-logger.rb', line 45

def warn(message=nil)
  @output << [:warn, message || yield]
end