GithubHelp home page GithubHelp logo

perl-debugger's Introduction

perl-debugger

Perl Debugger class

Features

  • Log method to log strings and scalar variables
  • Dump method to inspect data structures, objects and other variables
  • Provide stacktraces
  • Provide timing
    • Script
    • Methods only
    • Arbitrary points
  • A pure perl library

How to use

All you need to do is import the library by putting this in your script: use Debugger;

Constructor arguments

log_file => path/to/debug/file

This is optional and defaults to debug.log where the script is stored.

Examples

Object instantiation

my $debug = new Debugger();

Or my $debug = new Debugger({ 'log_file' => '/path/to/debug/file' });

Log a message or scalar variable

my $x = "some text in this variable";
$debug->log($x);

Will output some text in this variable into the log file.

Dump an object or variable

Example 1
my @lines = get_lines();

$debug->dump(\@lines);

Will output the contents of @lines to the log file.

Example 2
my $class = new Some::Class();
$debug->dump($class);

Time a script

# Top of script
my $debug = new Debugger(); # <- Time starts from constructor

... rest of script

$debug->timestamp(); # <- Provides time difference from constructor to this point and logs it

Provide a stacktrace

sub a_function_nested_deeply {
	my $self = shift;

	$debug->stacktrace(); # <- Provide how we got here via stacktrace;
}

Output a counter

my $debug = new Debugger();

while ($meets_criteria) {
	$debug->counter();

	$meets_criteria = check_criteria();
}

perl-debugger's People

Contributors

zsyed91 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.