Sha256: 5b2a18cc52bf596ea065e4e7d7be5c4cc0b85fc049150fcb82ab397698814d00

Contents?: true

Size: 707 Bytes

Versions: 1

Compression:

Stored size: 707 Bytes

Contents

#!/usr/bin/env ruby
require 'date'
require File.expand_path("../lib/log_slice", File.dirname(__FILE__))
if ARGV.length < 2
  $stderr.puts "USAGE:   #{$0} DATE [END_DATE] FILEPATH\n\n"
  $stderr.puts "EXAMPLE: #{$0} '2012-08-31 12:00:00' /tmp/something.log\n"
  $stderr.puts "EXAMPLE: #{$0} '2012-08-31 12:00:00' '2012-08-31 12:05:00' /tmp/something.log\n"
  $stderr.puts "Expects log lines to contain a DateTime string enclosed in [square brackets] \n\n"
end

start_date = ARGV[0]
(end_date, file) = begin
  if ARGV.length == 2
    [nil, ARGV[1]]
  else
    [ARGV[1], ARGV[2]]
  end
end

begin
  LogSlice::DateRange.new(file, start_date, end_date).each do |line|
    puts line
  end
rescue Errno::EPIPE
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
log_slice-0.4 bin/log_slice_date