DADA::App::LogSearch

- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- SUBROUTINES/METHODS

- new
- search
- html_highlight_line

- Example
- DIAGNOSTICS
- BUGS AND LIMITATIONS
- AUTHOR
- LICENCE AND COPYRIGHT

# NAME

DADA::App::LogSearch - Simple Searching of PlainText Logs for Dada Mail

# VERSION

Refer to the version of Dada Mail that this module comes in.

# SYNOPSIS

     my $query     = 'find me';
     my $searcher  = DADA::App::LogSearch->new;

     my $results   = $searcher->search({
            -query => $query,
            -files => ['/home/account/dada_files/logs/dada_usage.txt'],

     });

# DESCRIPTION

This module provides a very simple interface to find a term in a list of files that you supply.

# SUBROUTINES/METHODS

## new

Takes no arguments. Returns a DADA::App::LogSearch object.

## search

Takes two arguments - both are required. They are:

- -query

  Its value should be a string.

  This is the search term you're looking for. If you're search term has a space in it, for example, search term, this module will search for both search and term seperately.

- -files

  Its value should be an array ref

  This is the list of files you'd like to search in. Use absolute paths to these files, ala:

       my $results   = $searcher->search({
              -query => $query,
              -files => [
                         '/home/account/dada_files/logs/dada_usage.txt',
                         '/home/account/dada_files/logs/errors.txt'
                       ],

       });

This method will return a hashref. The key of the hashref is the name of the log file that you gave. Each value of the hashref is an arrayfref that holds the lines that match your query.

## html_highlight_line

Takes two arguments - both are required -

They are:

- -query

  Its value should be a string.

  This is the search term you're looking for.

- -line

  Its value is a string - basically, one of the results that the LogSearch object brings back.

# Example

Here's an example of how this object can be used:

      use DADA::App::LogSearch
      my $query     = 'find me';

      my $searcher  = DADA::App::LogSearch->new;

      my $results   = $searcher->search({
            -query => $query,
            -files => [
                       '/home/account/dada_files/logs/dada_usage.txt',
                       '/home/account/dada_files/logs/errors.txt'
                     ],

     });

     foreach my $file_name(keys %$results){
         if($results->{$file_name}->[0]){
             print '<h1>' . $file_name . '</h1>';
             foreach my $l(@{$results->{$file_name}}){
                 print '<p>' . $searcher->html_highlight_line({-query =>  $query, -line => $l }) . '</p>';
              }
          }
      }

# DIAGNOSTICS

# BUGS AND LIMITATIONS

Please report problems to the author of this module

# AUTHOR

Justin Simoni

See: http://dadamailproject.com/contact

# LICENCE AND COPYRIGHT

Copyright (c) 2006 - 2008 Justin Simoni All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.