NAME

Debug::Smart - Debug messages for smart logging to the file

VERSION

version 0.002

SYNOPSIS

use Debug::Smart -timestamp;

LOG("write a message");
DUMP("dump the data structures", $arg);
YAML("dump the data structures back into yaml", $arg)

DESCRIPTION

Debug::Smart provides debug methods that is easy to use.

This module automatically creates and opens the file for logging. It is created to location of the file that used this module. And the name of the file is the namespace + .debug_log with using this module. It exports a function that you can put just about anywhere in your Perl code to make it logging.

To change the location or filename, you can use the options. Please refer to OPTIONS for more information on.

package Example;

use Debug::Smart;
#file name "Example.debug_log"


package Example;

use Debug::Smart -name => 'mydebug.log';
#file name "mydebug.log"

WARNING: This module automatically determines the output location and the filename when you don't use some options. You should carefully use it, otherwise the file of same name is overwrited. And this module uses a source filter. If you don't like that, don't use this.

TRACE

You can trace the variables if you use -trace option. This option specifies the variable's name that is type of SCALAR or ARRAY_REF. TRACE function is automatically added by source code filter(Fillter::Util::Call) and outputs the specified variable's value that each time appeared in the source code.

# you shuld use sigle quote
use Debug::Smart -trace => '$var';

my $var = 1;
$var = 2;
$var = 10;

done.

my $var = 1;TRACE $var;
$var = 2;TRACE $var;
$var = 10; TRACE $var;

EXPORT

LOG

To write variable to the file.

DUMP

To write the variable structures to the file with Data::Dumper::Dumper.

YAML

To write the variable structures to the file with YAML::Dump.

TRACE

This function traces valiables. (TRACE is not export if you don't use -trace option)

CLOSE

This function closes the filehandle when you purposefully want to close it. Normally, this module closes the filehandle when the program ends.

OPTIONS

use Debug::Smart -path => '/path/to/';

-path option specify output location of the log file.

use Debug::Smart -name => 'filename';

-filename option specify the filename.

use Debug::Smart -timestamp;

-timestamp option add timestamp to the head of logging message.

use Debug::Smart -append

-append option is append mode. Writing at end-of-file. Default is write mode. It will be overwritten.

use Debug::Smart -trace => '$foo';
or
use Debug::Smart -trace => ['$foo', '$bar'];

-trace option traces the variable of specified the name. You should write the single quoted variable's name.

SEE ALSO

Filter::Util::Call

AUTHOR

Kazuhiro Shibuya, <k42uh1r0@gmail.com>

BUGS

Please report any bugs or feature requests to bug-debug-simple@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright 2007 Kazuhiro Shibuya, All Rights Reserved.

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