Method: CLI::UI.log_output_to
- Defined in:
- lib/cli/ui.rb
.log_output_to(path, &block) ⇒ Object
Duplicate output to a file path
Attributes
-
path- path to duplicate output to
: [T] (String path) { -> T } -> T
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/cli/ui.rb', line 254 def log_output_to(path, &block) if CLI::UI::StdoutRouter.duplicate_output_to raise 'multiple logs not allowed' end CLI::UI::StdoutRouter.duplicate_output_to = File.open(path, 'w') yield ensure if (file_descriptor = CLI::UI::StdoutRouter.duplicate_output_to) begin file_descriptor.close rescue IOError nil end CLI::UI::StdoutRouter.duplicate_output_to = nil end end |