From 92a800e6fac67504fe2160dc6cba80758db989cc Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 21 Apr 2008 23:45:47 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8158 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- scripts/extract_log_range.pl | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 scripts/extract_log_range.pl diff --git a/scripts/extract_log_range.pl b/scripts/extract_log_range.pl new file mode 100644 index 0000000000..a3dd575e95 --- /dev/null +++ b/scripts/extract_log_range.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl +use Time::Local; + +my $file = shift; +my $start = shift; +my $stop = shift; + + +sub parse_date($) { + my $str = shift; + + if (my ($yr, $mo, $day, $hr, $min, $sec) = $str =~ /(\d{4})\-(\d{2})\-(\d{2}) (\d{2})\:(\d{2})\:(\d{2})/) { + return timelocal($sec, $min, $hr, $day - 1, $mo - 1, $yr); + } else { + die $str; + } +} + +if ($start =~ /\:/) { + $start = parse_date($start); +} + +if ($stop =~ /\:/) { + $stop = parse_date($stop); +} elsif ($stop =~ /^\+(\d+)/) { + $stop = $start + $1; +} + +open(I, $file); + +while () { + my $str = $_; + $epoch = parse_date($str); + + if ($epoch > $start) { + if ($stop && $epoch > $stop) { + last; + } + print; + } +} + +close(I);