Earl Cahill > Log-Delimited-0.90 > Log::Delimited

Download:
Log-Delimited-0.90.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.90   Source  

NAME ^

Log::Delimited - simple module to help log results

SYNOPSIS ^

#!/usr/bin/perl -w

use strict; use Log::Delimited;

my $log = Log::Delimited->new({ log_cols => ['url', 'step', 'elapsed'], log_info => ['http://slap.com/cgi-bin/slow_script', 'step 1', '99993.0923'], })->log;

$log->{log_info} = ['http://slap.com/cgi-bin/slow_script', 'step 2', '8.3240']; $log->log;

DESCRIPTION ^

  Log is sort of a dumb program that leads to sort of smart stuff.  

It takes some columns ('this', 'that', 'else'), some data ('rulz', 'rocks!', 'do something') and a delimiter ('|'), and makes a file that looks like this

this|that|else

my_hostname|12342|1000204952|rulz|rocksrocks%21|do+something

the first row is a join($delimiter, @column_names), the second (in a little pseudo code) forms

@data = ($hostname, $pid, time, $array_ref_of_your_passed_data)

then forms the row with join($delimiter, URLEncode(@data)). By the way, you can turn off the hostname, pid and time inclusion, but in most applications, they have come in handy. To turn them off just set which applies from below

  $self->{no_hostname} = 1;
  $self->{no_pid} = 1;
  $self->{no_time} = 1;

To turn off Url encoding, just set

  $self->{no_URLEncode} = 1;

In this document, $self is a Log::Delimited object.

The log directory is

$self->{base_dir} = "/tmp/logs"; $self->{log_dir} ||= "$self->{base_dir}/$self->{log_node}";

Log uses the last part of your script name ($0) for the log_node if you don't pass one.

The log file is

$self->{log_filename} ||= "$self->{log_dir}/$self->{log_name}";

Log uses the last part of your script name ($0) for the log_name if you don't pass one.

Since logs can get to be quite large, you can easily zip, by doing

$self->zip;

If you have a large log, where size is a bigger issue than speed you can do

$self->log_zipped;

which will result in just a zipped log file.

EXAMPLE ^

#!/usr/bin/perl -w

use strict; use Log::Delimited;

my $log = Log::Delimited->new({ log_node => 'slap', log_name => 'cool_path', log_cols => ['url', 'step', 'elapsed'], log_info => ['http://slap.com/cgi-bin/slow_script', 'step 1', '99993.0923'], })->log;

$log->{log_info} = ['http://slap.com/cgi-bin/slow_script', 'step 2', '8.3240']; $log->log;

ZIP EXAMPLE ^

#!/usr/bin/perl -w

use strict; use Log::Delimited;

my $log = Log::Delimited->new({ log_cols => ['url', 'step', 'elapsed'], }); $log->{log_info} = ['http://slap.com/cgi-bin/slow_script', 'step 1', '99993.0923']; $log->zipped_log;

AUTHOR ^

Earl Cahill, cpan@spack.net

syntax highlighting: