```ruby
module Ld4lBrowserData
  module Utilities
    module ReportHelper
      def initialize(main_routine, path)
        @main_routine = main_routine
        @file = File.open(path, 'w')
      end

      def logit(message)
        m = "#{Time.new.strftime('%Y-%m-%d %H:%M:%S')} #{message}"
        puts m
        @file.puts m
      end

      def log_header(args)
        logit "#{@main_routine} #{args.join(' ')}"
      end

      def close
        @file.close if @file
      end
    end
  end
end```

Improve the logging of both $stdout and $stderr; add a method to report HTTP stats.
user
```ruby
module Ld4lBrowserData
  module Utilities
    module ReportHelper
      #
      # Record stdout and stderr, even while they are being displayed.
      #
      class MultiIO
        def initialize(*targets)
          @targets = targets
        end

        def write(*args)
          @targets.each {|t| t.write(*args)}
        end

        def flush()
          @targets.each(&:flush)
        end

        def close
          @targets.each(&:close)
        end
      end

      def initialize(main_routine, path)
        @main_routine = main_routine
        
        @file = File.open(path, 'w')
        @file.sync = true
        $stdout = MultiIO.new($stdout, @file)
        $stderr = MultiIO.new($stderr, @file)
      end

      def logit(message)
        puts "#{Time.new.strftime('%Y-%m-%d %H:%M:%S')} #{message}"
      end

      def log_header(args)
        logit "#{@main_routine} #{args.join(' ')}"
      end

      def summarize_http_status(ts)
        begin
          return unless ts
          return unless ts.respond_to?(:http_counts)
          
          counts = ts.http_counts
          return unless counts
          
          total = counts.reduce(0) {|sum, m| sum += m[1].values.reduce(0, :+)} 
          return unless total > 0
          
          logit "http counts: #{counts.inspect}, total = #{total}"
        rescue
          logit "No HTTP status: #{$!}"
        end
      end

      def close
        @file.close if @file
      end
    end
  end
end```
assistant