1

I have a class ChildProcess from childprocess gem. It expects me to configure logging this way:

process = ChildProcess.build(...)
process.io.stdout = Tempfile.new("/tmp/file.txt")

However, I don't have a file to log to. Instead, I have an instance of Logger class. I need to find a way to create a wrapper around Logger in order to make it look like an "writeable stream" (I'm not sure what it means in this case, though). Do you know a gem to help me do this?

yegor256
  • 102,010
  • 123
  • 446
  • 597

1 Answers1

-1

I'm no expert, but couldn't you use the IO.pipe as shown here and pass that to the Logger?

Arun D'souza
  • 182
  • 12
  • I've not used the Logger, but it looks like you send messages to an instance [using functions](https://ruby-doc.org/stdlib-2.4.0/libdoc/logger/rdoc/Logger.html#class-Logger-label-How+to+log+a+message). So instead of the `print` function show in the [link in my example](https://github.com/enkessler/childprocess#output-to-pipe), can't you use the `logger.info` (or whatever you need) with the logger instance that you have? – Arun D'souza Sep 09 '19 at 17:04