Footprintless::Log

- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- ENTITIES
- CONSTRUCTORS
  - new($entity, $coordinate, %options)
- METHODS
  - cat(%options)
  - follow(%options)
  - grep(%options)
  - head(%options)
  - tail(%options)
- AUTHOR
- COPYRIGHT AND LICENSE
- SEE ALSO

# NAME

Footprintless::Log - A log manager

# VERSION

version 1.03

# SYNOPSIS

        # Standard way of getting a log
        use Footprintless;
        my $log = Footprintless->new()->log();

        # Wait for a started message before proceeding
        $log->follow(until => qr/Started in \d+/);

        # Check for errors during startup
        my $error_messages = $log->grep(options => {'ERROR'});

# DESCRIPTION

Provides access to read from log files.

# ENTITIES

A log entity can be a simple entity:

        catalina => '/opt/tomcat/logs/catalina.out'

Or it can be a hashref entity containing, at minimum, a `file` entity:

        catalina => {
            file => '/var/log/external/web/catalina.out',
            hostname => 'loghost.pastdev.com'
        }

All unspecified command options will be inherited (`hostname`, `ssh`, `sudo_username`, `username`) from their ancestry. Logs are commonly grouped together:

        web => {
            hostname => 'web.pastdev.com',
            logs => {
                error => '/var/log/httpd/error_log',
                access => '/var/log/httpd/access_log'
                catalina => {
                    file => '/opt/tomcat/logs/catalina.out',
                    hostname => 'app.pastdev.com',
                    sudo_username => 'tomcat'
                }
            }
            sudo_username => 'apache'
        }

# CONSTRUCTORS

## new($entity, $coordinate, %options)

Constructs a new log manager configured by the `$entities` at `$coordinate`. The supported options are:

command_options_factory

  The command options factory to use. Defaults to an instance of Footprintless::CommandOptionsFactory using the `localhost` instance of this object.

command_runner

  The command runner to use. Defaults to an instance of Footprintless::CommandRunner::IPCRun.

localhost

  The localhost alias resolver to use. Defaults to an instance of Footprintless::Localhost configured with `load_all()`.

# METHODS

## cat(%options)

Executes the `cat` command on this log. The available options are:

options

  Command line options passed to the `cat` command

## follow(%options)

Executes the `tail` command with the `-f` (follow) option and sets the command runner options to pass the `STDOUT` from tail to this `STDOUT`.

runner_options

  Runner options to be passed on to the command runner.

until

  The command will stop once the regex supplied is matched to the output.

## grep(%options)

Executes the `grep` command on this log. The available options are:

options

  Command line options passed to the `grep` command

## head(%options)

Executes the `head` command on this log. The available options are:

options

  Command line options passed to the `head` command

## tail(%options)

Executes the `tail` command on this log. The available options are:

options

  Command line options passed to the `tail` command

# AUTHOR

Lucas Theisen <lucastheisen@pastdev.com>

# COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Lucas Theisen.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

# SEE ALSO

Please see those modules/websites for more information related to this module.

- Footprintless
- Config::Entities
- Footprintless
- Footprintless::CommandOptionsFactory
- Footprintless::CommandRunner
- Footprintless::Localhost