Class: Vigilant::StdoutInterceptor
- Inherits:
-
Object
- Object
- Vigilant::StdoutInterceptor
show all
- Defined in:
- lib/vigilant-ruby/logger.rb
Overview
Interceptor for capturing stdout
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StdoutInterceptor.
171
172
173
174
|
# File 'lib/vigilant-ruby/logger.rb', line 171
def initialize(logger, original)
@logger = logger
@original = original
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
217
218
219
|
# File 'lib/vigilant-ruby/logger.rb', line 217
def method_missing(meth, *args, &blk)
@original.send(meth, *args, &blk)
end
|
Instance Method Details
#close ⇒ Object
205
206
207
|
# File 'lib/vigilant-ruby/logger.rb', line 205
def close
@original.close
end
|
#flush ⇒ Object
201
202
203
|
# File 'lib/vigilant-ruby/logger.rb', line 201
def flush
@original.flush
end
|
#print(*messages) ⇒ Object
188
189
190
191
192
193
|
# File 'lib/vigilant-ruby/logger.rb', line 188
def print(*messages)
messages.each do |m|
@logger.info(m.to_s.strip, _autocapture: true) unless m.to_s.strip.empty?
end
@original.print(*messages)
end
|
#printf(*args) ⇒ Object
195
196
197
198
199
|
# File 'lib/vigilant-ruby/logger.rb', line 195
def printf(*args)
formatted = sprintf(*args)
@logger.info(formatted.strip, _autocapture: true) unless formatted.strip.empty?
@original.printf(*args)
end
|
#puts(*messages) ⇒ Object
181
182
183
184
185
186
|
# File 'lib/vigilant-ruby/logger.rb', line 181
def puts(*messages)
messages.each do |m|
@logger.info(m.to_s.strip, _autocapture: true) unless m.to_s.strip.empty?
end
@original.puts(*messages)
end
|
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
213
214
215
|
# File 'lib/vigilant-ruby/logger.rb', line 213
def respond_to_missing?(meth, include_private = false)
@original.respond_to?(meth, include_private)
end
|
#tty? ⇒ Boolean
209
210
211
|
# File 'lib/vigilant-ruby/logger.rb', line 209
def tty?
@original.tty?
end
|
#write(message) ⇒ Object
176
177
178
179
|
# File 'lib/vigilant-ruby/logger.rb', line 176
def write(message)
@logger.info(message.strip, _autocapture: true) unless message.strip.empty?
@original.write(message)
end
|