Logfile.pm 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. package Pisg::Parser::Logfile;
  2. # Copyright and license, as well as documentation(POD) for this module is
  3. # found at the end of the file.
  4. use strict;
  5. $^W = 1;
  6. sub new
  7. {
  8. my $type = shift;
  9. my %args = @_;
  10. my $self = {
  11. cfg => $args{cfg},
  12. parser => undef
  13. };
  14. # Import common functions in Pisg::Common
  15. require Pisg::Common;
  16. Pisg::Common->import();
  17. bless($self, $type);
  18. # Pick our parser.
  19. $self->{parser} = $self->_choose_format($self->{cfg}->{format});
  20. return $self;
  21. }
  22. # The function to choose which module to use.
  23. sub _choose_format
  24. {
  25. my $self = shift;
  26. my $format = shift;
  27. $self->{parser} = undef;
  28. eval <<_END;
  29. use lib '$self->{cfg}->{modules_dir}';
  30. use Pisg::Parser::Format::$format;
  31. \$self->{parser} = new Pisg::Parser::Format::$format(
  32. cfg => \$self->{cfg},
  33. );
  34. _END
  35. if ($@) {
  36. print STDERR "Could not load parser for '$format': $@\n";
  37. return undef;
  38. }
  39. return $self->{parser};
  40. }
  41. sub analyze
  42. {
  43. my $self = shift;
  44. my (%stats, %lines);
  45. if (defined $self->{parser}) {
  46. my $starttime = time();
  47. # Just initialize these to 0
  48. $stats{days} = 0;
  49. $stats{parsedlines} = 0;
  50. $stats{totallines} = 0;
  51. if (scalar(@{$self->{cfg}->{logdir}}) > 0) {
  52. # Run through all files in dir
  53. $self->_parse_dir(\%stats, \%lines);
  54. } else {
  55. my %state = (
  56. linecount => 0,
  57. lastnick => '',
  58. monocount => 0,
  59. lastnormal => '',
  60. oldtime => 24
  61. );
  62. foreach my $logfile (@{$self->{cfg}->{logfile}}) {
  63. # Run through the whole logfile
  64. $self->_parse_file(\%stats, \%lines, $logfile, \%state);
  65. }
  66. }
  67. $self->_pick_random_lines(\%stats, \%lines);
  68. _uniquify_nicks(\%stats);
  69. my ($sec,$min,$hour) = gmtime(time() - $starttime);
  70. my $processtime = sprintf('%02d hours, %02d minutes and %02d seconds', $hour, $min, $sec);
  71. $stats{processtime}{hours} = sprintf('%02d', $hour);
  72. $stats{processtime}{mins} = sprintf('%02d', $min);
  73. $stats{processtime}{secs} = sprintf('%02d', $sec);
  74. print "Channel analyzed succesfully in $processtime on ",
  75. scalar localtime(time()), "\n"
  76. unless ($self->{cfg}->{silent});
  77. return \%stats;
  78. } else {
  79. print STDERR "Skipping channel '$self->{cfg}->{channel}' due to lack of parser.\n";
  80. return undef
  81. }
  82. # Shouldn't get here.
  83. return undef;
  84. }
  85. sub _parse_dir
  86. {
  87. my $self = shift;
  88. my ($stats, $lines) = @_;
  89. # Loop through each logdir we were given
  90. foreach my $logdir (@{$self->{cfg}->{logdir}}) {
  91. # Add trailing slash when it's not there..
  92. $logdir =~ s/([^\/])$/$1\//;
  93. unless ($self->{cfg}->{silent}) {
  94. unless ($self->{cfg}->{nfiles} > 0) {
  95. print "Going into $logdir and parsing all files there...\n\n"
  96. } else {
  97. print "Going into $logdir and parsing the last $self->{cfg}->{nfiles} file(s) there...\n\n"
  98. }
  99. }
  100. my @filesarray;
  101. opendir(LOGDIR, $logdir) or
  102. die("Can't opendir ${logdir}: $!");
  103. @filesarray = grep {
  104. /^[^\.]/ && /^$self->{cfg}->{logprefix}/ && -f "$logdir/$_"
  105. } readdir(LOGDIR) or
  106. die("No files in \"$logdir\" matched prefix \"$self->{cfg}->{logprefix}\"");
  107. closedir(LOGDIR);
  108. my %state = (
  109. lastnick => '',
  110. monocount => 0,
  111. oldtime => 24
  112. );
  113. if ($self->{cfg}->{logsuffix} ne '') {
  114. my @temparray;
  115. my %months = (
  116. 'jan' => '0',
  117. 'feb' => '1',
  118. 'mar' => '2',
  119. 'apr' => '3',
  120. 'may' => '4',
  121. 'jun' => '5',
  122. 'jul' => '6',
  123. 'aug' => '7',
  124. 'sep' => '8',
  125. 'oct' => '9',
  126. 'nov' => '10',
  127. 'dec' => '11',
  128. );
  129. my ($mreg, $dreg, $yreg) = split(/\|\|/, $self->{cfg}->{logsuffix});
  130. my (@month, @day, @year);
  131. for my $file (@filesarray) {
  132. LOOPSTART:
  133. if ($file =~ /$mreg/) {
  134. my $month = $1;
  135. $month = lc $month;
  136. $month = $months{$month}
  137. if (defined $months{$month});
  138. push @month, $month;
  139. } else {
  140. splice(@filesarray,$#month + 1, 1);
  141. if ($file = $filesarray[$#month + 1]) {
  142. goto LOOPSTART;
  143. } else {
  144. last;
  145. }
  146. }
  147. if ($file =~ /$dreg/) {
  148. push @day, $1;
  149. } else {
  150. splice(@filesarray,$#day + 1, 1);
  151. splice(@month,$#day + 1);
  152. if ($file = $filesarray[$#day + 1]) {
  153. goto LOOPSTART;
  154. } else {
  155. last;
  156. }
  157. }
  158. if ($file =~ /$yreg/) {
  159. push @year, $1;
  160. } else {
  161. splice(@filesarray,$#year + 1, 1);
  162. splice(@month,$#year + 1);
  163. splice(@day,$#year + 1);
  164. if ($file = $filesarray[$#year + 1]) {
  165. goto LOOPSTART;
  166. } else {
  167. last;
  168. }
  169. }
  170. }
  171. my @newarray = @filesarray[ sort {
  172. $year[$a] <=> $year[$b]
  173. ||
  174. $month[$a] <=> $month[$b]
  175. ||
  176. $day[$a] <=> $day[$b]
  177. } 0..$#filesarray ];
  178. @filesarray = @newarray;
  179. } else {
  180. @filesarray = sort {lc($a) cmp lc($b)} @filesarray;
  181. }
  182. if($self->{cfg}->{nfiles} > 0) {
  183. my $shift = @filesarray - $self->{cfg}->{nfiles};
  184. splice(@filesarray, 0, $shift);
  185. }
  186. foreach my $file (@filesarray) {
  187. $file = $logdir . $file;
  188. $self->_parse_file($stats, $lines, $file, \%state);
  189. }
  190. }
  191. }
  192. # This parses the file...
  193. sub _parse_file
  194. {
  195. my $self = shift;
  196. my ($stats, $lines, $file, $state) = @_;
  197. print "Analyzing log($file) in '$self->{cfg}->{format}' format...\n"
  198. unless ($self->{cfg}->{silent});
  199. if ($file =~ /.bz2?$/ && -f $file) {
  200. open (LOGFILE, "bunzip2 -c $file |") or
  201. die("$0: Unable to open logfile($file): $!\n");
  202. } elsif ($file =~ /.gz$/ && -f $file) {
  203. open (LOGFILE, "gunzip -c $file |") or
  204. die("$0: Unable to open logfile($file): $!\n");
  205. } else {
  206. open (LOGFILE, $file) or
  207. die("$0: Unable to open logfile($file): $!\n");
  208. }
  209. my $lastnormal = '';
  210. while(my $line = <LOGFILE>) {
  211. $line = _strip_mirccodes($line);
  212. $line =~ s/\r+$//; # Strip DOS Formatting
  213. my $hashref;
  214. # Match normal lines.
  215. if ($hashref = $self->{parser}->normalline($line, $.)) {
  216. my $repeated = 0;
  217. if (defined $hashref->{repeated}) {
  218. $repeated = $hashref->{repeated};
  219. }
  220. my ($hour, $nick, $saying, $i);
  221. for ($i = 0; $i <= $repeated; $i++) {
  222. if ($i > 0) {
  223. $hashref = $self->{parser}->normalline($lastnormal, $.);
  224. #Increment number of lines for repeated lines
  225. }
  226. $hour = $self->_adjusttimeoffset($hashref->{hour});
  227. $nick = find_alias($hashref->{nick});
  228. checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{showmostnicks});
  229. $saying = $hashref->{saying};
  230. if ($hour < $state->{oldtime}) {
  231. $stats->{days}++;
  232. $stats->{day_times}{$stats->{days}}[0] = 0;
  233. $stats->{day_times}{$stats->{days}}[1] = 0;
  234. $stats->{day_times}{$stats->{days}}[2] = 0;
  235. $stats->{day_times}{$stats->{days}}[3] = 0;
  236. $stats->{day_lines}{$stats->{days}} = 0;
  237. }
  238. $state->{oldtime} = $hour;
  239. if (!is_ignored($nick)) {
  240. $stats->{parsedlines}++;
  241. # Timestamp collecting
  242. $stats->{times}{$hour}++;
  243. $stats->{day_times}{$stats->{days}}[int($hour/6)]++;
  244. $stats->{day_lines}{$stats->{days}}++;
  245. $stats->{lines}{$nick}++;
  246. $stats->{lastvisited}{$nick} = $stats->{days};
  247. $stats->{line_times}{$nick}[int($hour/6)]++;
  248. # Count up monologues
  249. if ($state->{lastnick} eq $nick) {
  250. $state->{monocount}++;
  251. if ($state->{monocount} == 5) {
  252. $stats->{monologues}{$nick}++;
  253. }
  254. } else {
  255. $state->{monocount} = 0;
  256. }
  257. $state->{lastnick} = $nick;
  258. my $len = length($saying);
  259. if ($len > $self->{cfg}->{minquote} && $len < $self->{cfg}->{maxquote}) {
  260. push @{ $lines->{sayings}{$nick} }, $saying;
  261. } elsif (!$lines->{sayings}{$nick}) {
  262. # Just fill the users first saying in if he hasn't
  263. # said anything yet, to get rid of empty quotes.
  264. push @{ $lines->{sayings}{$nick} }, substr($saying, 0, $self->{cfg}->{maxquote});
  265. }
  266. $stats->{lengths}{$nick} += $len;
  267. $stats->{questions}{$nick}++
  268. if (index($saying, '?') > -1);
  269. $stats->{shouts}{$nick}++
  270. if (index($saying, '!') > -1);
  271. study $saying;
  272. if ($saying !~ /[a-z]/o && $saying =~ /[A-Z]/o) {
  273. # Ignore single smileys on a line. eg. '<user> :P'
  274. if ($saying !~ /^[8;:=][ ^-o]?[)pPD}\]>]$/o) {
  275. $stats->{allcaps}{$nick}++;
  276. push @{ $lines->{allcaplines}{$nick} }, $line;
  277. }
  278. }
  279. if (my @foul = $saying =~ /($self->{cfg}->{foulwords})/io) {
  280. $stats->{foul}{$nick} += scalar @foul;
  281. push @{ $lines->{foullines}{$nick} }, $line;
  282. }
  283. # Who smiles the most?
  284. # A regex matching al lot of smilies
  285. $stats->{smiles}{$nick}++
  286. if ($saying =~ /[8;:=][ ^-o]?[)pPD}\]>]/o);
  287. if ($saying =~ /[8;:=][ ^-]?[\(\[\\\/{]/o and
  288. $saying !~ /\w+:\/\//o) {
  289. $stats->{frowns}{$nick}++;
  290. }
  291. # Find URLs
  292. if (my @urls = match_urls($saying)) {
  293. foreach my $url (@urls) {
  294. if(!url_is_ignored($url)) {
  295. $url =~ s/&/&amp;/g;
  296. $stats->{urlcounts}{$url}++;
  297. $stats->{urlnicks}{$url} = $nick;
  298. }
  299. }
  300. }
  301. _parse_words($stats, $saying, $nick, $self->{cfg}->{ignorewords}, $hour);
  302. }
  303. }
  304. $lastnormal = $line;
  305. $repeated = 0;
  306. }
  307. # Match action lines.
  308. elsif ($hashref = $self->{parser}->actionline($line, $.)) {
  309. $stats->{parsedlines}++;
  310. my ($hour, $nick, $saying);
  311. $hour = $self->_adjusttimeoffset($hashref->{hour});
  312. $nick = find_alias($hashref->{nick});
  313. checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{showmostnicks});
  314. $saying = $hashref->{saying};
  315. if ($hour < $state->{oldtime}) {
  316. $stats->{days}++;
  317. $stats->{day_times}{$stats->{days}}[0] = 0;
  318. $stats->{day_times}{$stats->{days}}[1] = 0;
  319. $stats->{day_times}{$stats->{days}}[2] = 0;
  320. $stats->{day_times}{$stats->{days}}[3] = 0;
  321. $stats->{day_lines}{$stats->{days}} = 0;
  322. }
  323. $state->{oldtime} = $hour;
  324. if (!is_ignored($nick)) {
  325. # Timestamp collecting
  326. $stats->{times}{$hour}++;
  327. $stats->{day_times}{$stats->{days}}[int($hour/6)]++;
  328. $stats->{day_lines}{$stats->{days}}++;
  329. $stats->{actions}{$nick}++;
  330. push @{ $lines->{actionlines}{$nick} }, $line;
  331. $stats->{lines}{$nick}++;
  332. $stats->{lastvisited}{$nick} = $stats->{days};
  333. $stats->{line_times}{$nick}[int($hour/6)]++;
  334. if ($saying =~ /^($self->{cfg}->{violentwords}) (\S+)(.*)/o) {
  335. my $victim;
  336. unless ($victim = is_nick($2)) {
  337. foreach my $trynick (split(/\s+/, $3)) {
  338. last if ($victim = is_nick($trynick));
  339. }
  340. unless ($victim) {
  341. $victim = $2;
  342. }
  343. }
  344. if (!is_ignored($victim)) {
  345. $stats->{violence}{$nick}++;
  346. $stats->{attacked}{$victim}++;
  347. push @{ $lines->{violencelines}{$nick} }, $line;
  348. push @{ $lines->{attackedlines}{$victim} }, $line;
  349. }
  350. }
  351. $stats->{lengths}{$nick} += length($saying);
  352. _parse_words($stats, $saying, $nick, $self->{cfg}->{ignorewords}, $hour);
  353. }
  354. }
  355. # Match *** lines.
  356. elsif (($hashref = $self->{parser}->thirdline($line, $.)) and $hashref->{nick}) {
  357. $stats->{parsedlines}++;
  358. my ($hour, $min, $nick, $kicker, $newtopic, $newmode, $newjoin);
  359. my ($newnick);
  360. $hour = $self->_adjusttimeoffset($hashref->{hour});
  361. $min = $hashref->{min};
  362. $nick = find_alias($hashref->{nick});
  363. checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{showmostnicks});
  364. $kicker = find_alias($hashref->{kicker})
  365. if ($hashref->{kicker});
  366. $newtopic = $hashref->{newtopic};
  367. $newmode = $hashref->{newmode};
  368. $newjoin = $hashref->{newjoin};
  369. $newnick = $hashref->{newnick};
  370. if ($hour < $state->{oldtime}) {
  371. $stats->{days}++;
  372. $stats->{day_times}{$stats->{days}}[0]=0;
  373. $stats->{day_times}{$stats->{days}}[1]=0;
  374. $stats->{day_times}{$stats->{days}}[2]=0;
  375. $stats->{day_times}{$stats->{days}}[3]=0;
  376. $stats->{day_lines}{$stats->{days}}=0;
  377. }
  378. $state->{oldtime} = $hour;
  379. if (!is_ignored($nick)) {
  380. # Timestamp collecting
  381. $stats->{times}{$hour}++;
  382. $stats->{day_times}{$stats->{days}}[int($hour/6)]++;
  383. $stats->{day_lines}{$stats->{days}}++;
  384. $stats->{lastvisited}{$nick} = $stats->{days};
  385. if (defined($kicker)) {
  386. if (!is_ignored($kicker)) {
  387. $stats->{kicked}{$kicker}++;
  388. $stats->{gotkicked}{$nick}++;
  389. push @{ $lines->{kicklines}{$nick} }, $line;
  390. }
  391. } elsif (defined($newtopic) && $newtopic ne '') {
  392. _topic_change($stats, $newtopic, $nick, $hour, $min);
  393. } elsif (defined($newmode)) {
  394. _modechanges($stats, $newmode, $nick);
  395. } elsif (defined($newjoin)) {
  396. $stats->{joins}{$nick}++;
  397. } elsif (defined($newnick) and ($self->{cfg}->{nicktracking} == 1)) {
  398. # Resolve new nick to the correct alias (this will create a hard-alias if it is using a regex)
  399. $newnick = find_alias($newnick);
  400. add_alias($nick, $newnick);
  401. checkname($nick, $newnick, $stats) if ($self->{cfg}->{showmostnicks});
  402. }
  403. }
  404. }
  405. }
  406. $stats->{totallines} = $.;
  407. close(LOGFILE);
  408. print "Finished analyzing log, $stats->{days} days total.\n"
  409. unless ($self->{cfg}->{silent});
  410. }
  411. sub _topic_change
  412. {
  413. my $stats = shift;
  414. my $newtopic = shift;
  415. my $nick = shift;
  416. my $hour = shift;
  417. my $min = shift;
  418. my $tcount = 0;
  419. if (defined $stats->{topics}) {
  420. $tcount = @{ $stats->{topics} };
  421. }
  422. $stats->{topics}[$tcount]{topic} = $newtopic;
  423. $stats->{topics}[$tcount]{nick} = $nick;
  424. $stats->{topics}[$tcount]{hour} = $hour;
  425. $stats->{topics}[$tcount]{min} = $min;
  426. }
  427. sub _modechanges
  428. {
  429. my $stats = shift;
  430. my $newmode = shift;
  431. my $nick = shift;
  432. my (@voice, @halfops, @ops, $plus);
  433. foreach (split(//, $newmode)) {
  434. if ($_ eq 'o') {
  435. $ops[$plus]++;
  436. } elsif ($_ eq 'h') {
  437. $halfops[$plus]++;
  438. } elsif ($_ eq 'v') {
  439. $voice[$plus]++;
  440. } elsif ($_ eq '+') {
  441. $plus = 0;
  442. } elsif ($_ eq '-') {
  443. $plus = 1;
  444. }
  445. }
  446. $stats->{gaveops}{$nick} += $ops[0] if $ops[0];
  447. $stats->{tookops}{$nick} += $ops[1] if $ops[1];
  448. $stats->{gavehalfops}{$nick} += $halfops[0] if $halfops[0];
  449. $stats->{tookhalfops}{$nick} += $halfops[1] if $halfops[1];
  450. $stats->{gavevoice}{$nick} += $voice[0] if $voice[0];
  451. $stats->{tookvoice}{$nick} += $voice[1] if $voice[1];
  452. }
  453. sub _parse_words
  454. {
  455. my ($stats, $saying, $nick, $ignorewords, $hour) = @_;
  456. # Cache time of day
  457. my $tod = int($hour/6);
  458. my $word;
  459. study $saying;
  460. $saying =~ s/[\s,!?.:;)(\"]+//o;
  461. while ($saying =~ s/([^\s,!?.:;)(\"]+)[\s,!?.:;)(\"]+//og) {
  462. $word = $1;
  463. $stats->{words}{$nick}++;
  464. $stats->{word_times}{$nick}[$tod]++;
  465. # remove uninteresting words
  466. next if $ignorewords and $word =~ m/$ignorewords/io;
  467. # TODO: does the /o above provide the correct behaviour?
  468. # next if $ignorewords and $word =~ m/$ignorewords/i;
  469. # ignore contractions
  470. next if ($word =~ m/'.{1,2}$/o);
  471. # Also ignore stuff from URLs.
  472. next if ($word =~ m/^https?$|^\/\//o);
  473. $stats->{wordcounts}{$word}++;
  474. $stats->{wordnicks}{$word} = $nick;
  475. }
  476. }
  477. sub _pick_random_lines
  478. {
  479. my ($self, $stats, $lines) = @_;
  480. foreach my $key (keys %{ $lines }) {
  481. foreach my $nick (keys %{ $lines->{$key} }) {
  482. $stats->{$key}{$nick} = $self->_random_line($stats, $lines, $key, $nick, 0);
  483. }
  484. }
  485. }
  486. sub _random_line
  487. {
  488. my ($self, $stats, $lines, $key, $nick, $count) = @_;
  489. my $random = ${ $lines->{$key}{$nick} }[rand@{ $lines->{$key}{$nick} }];
  490. if ($self->{cfg}->{noignoredquotes} && $random =~ /$self->{cfg}->{ignorewords}/io) {
  491. return '' if ($count > 20);
  492. return $self->_random_line($stats, $lines, $key, $nick, ++$count);
  493. } else {
  494. return $random;
  495. }
  496. }
  497. sub _uniquify_nicks {
  498. my ($stats) = @_;
  499. foreach my $word (keys %{ $stats->{wordcounts} }) {
  500. if (my $realnick = is_nick($word)) {
  501. # The lc() is an attempt at being case insensitive.
  502. if (lc($realnick) ne lc($word)) {
  503. $stats->{wordcounts}{$realnick} += $stats->{wordcounts}{$word};
  504. $stats->{wordnicks}{$realnick} = $stats->{wordnicks}{$word};
  505. delete $stats->{wordcounts}{$word};
  506. delete $stats->{wordnicks}{$word};
  507. }
  508. }
  509. }
  510. }
  511. sub _strip_mirccodes
  512. {
  513. my $line = shift;
  514. # boldcode = chr(2) = oct 001
  515. # colorcode = chr(3) = oct 003
  516. # plaincode = chr(15) = oct 017
  517. # reversecode = chr(22) = oct 026
  518. # underlinecode = chr(31) = oct 037
  519. # Strip mIRC color codes
  520. $line =~ s/\003\d{1,2},\d{1,2}//go;
  521. $line =~ s/\003\d{0,2}//go;
  522. # Strip mIRC bold, plain, reverse and underline codes
  523. $line =~ s/[\002\017\026\037]//go;
  524. return $line;
  525. }
  526. sub checkname {
  527. # This function tracks nickchanges and puts them all in a hash->array,
  528. # so we can show all nicks that I user had later (only works properly
  529. # when nicktracking is enabled)
  530. my ($nick, $newnick, $stats) = @_;
  531. $stats->{nicks}{$newnick}{lc($nick)} = $nick;
  532. }
  533. sub _adjusttimeoffset
  534. {
  535. my ($self, $hour) = @_;
  536. if ($self->{cfg}{timeoffset} != 0) {
  537. # Adjust time
  538. $hour += $self->{cfg}{timeoffset};
  539. $hour = $hour % 24;
  540. }
  541. return sprintf('%02d', $hour);
  542. }
  543. 1;
  544. __END__
  545. =head1 NAME
  546. Pisg::Parser::Logfile - class to parse a normal logfile
  547. =head1 DESCRIPTION
  548. C<Pisg::Parser::Logfile> parses a logfile using the configuration variables set in the 'cfg' option passed to the constructor.
  549. =head1 SYNOPSIS
  550. use Pisg::Parser::Logfile;
  551. $analyzer = new Pisg::Parser::Logfile(
  552. cfg => $cfg,
  553. );
  554. =head1 CONSTRUCTOR
  555. =over 4
  556. =item new ( [ OPTIONS ] )
  557. This is the constructor for a new Pisg::Parser::Logfile object. C<OPTIONS> are passed in a hash like fashion using key and value pairs.
  558. Possible options are:
  559. B<cfg> - hashref containing configuration variables, created by the Pisg module.
  560. =back
  561. =head1 AUTHOR
  562. Morten Brix Pedersen <morten@wtf.dk>
  563. =head1 COPYRIGHT
  564. Copyright (C) 2001 Morten Brix Pedersen. All rights resereved.
  565. This program is free software; you can redistribute it and/or modify it
  566. under the terms of the GPL, license is included with the distribution of
  567. this file.
  568. =cut