New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

io-tee

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-tee

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

IO::Tee

Copies stdout (or any other IO stream) contents to a file or another stream. Works with subprocesses too.

Example 1

# io-tee-demo.rb
require 'io/tee'

$stdout.tee('output.log')

puts "Hello, world!"

$stdout is effectively copied into file output.log while still being streamed as a standard output.

$ ruby io-tee-demo.rb
Hello, world!

$ cat output.log
Hello, world!

Example 2

Obviously it works with more than one stream copied into the same file

# io-tee-demo.rb
require 'io/tee'

$stdout.tee('full-output.log')
$stderr.tee('full-output.log')

puts 'Hello, world'
$stderr.puts '[DEBUG] Debug info'

One can suppress stderr during execution but still get it logged into a file alongside stdout

$ ruby io-tee-demo.rb 2> /dev/null
Hello, world

$ cat full-output.log
Hello, world
[DEBUG] Debug info

Append or overwrite

A keyword argument of append: false can be passed to the IO#tee method in order to overwrite the given file upon start of writing.

Sponsored by Veeqo

FAQs

Package last updated on 04 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc