Code Monkey home page Code Monkey logo

data-trace's Introduction

NAME

Data::Trace - Trace when a data structure gets updated.

SYNOPSIS

Variable change trace:

use Data::Trace;

my $data = {a => [0, {complex => 1}]};

sub BadCall{ $data->{a}[0] = 1 }

Trace($data);

BadCall();  # Shows stack trace of where data was changed.

Stack trace:

use Data::Trace;
Trace();    # 1 level.
Trace(5);   # 5 levels.

DESCRIPTION

This module provides a convienient way to find out when a data structure has been updated.

It is a debugging/tracing aid for complex systems to identify unintentional alteration to data structures which should be treated as read-only.

Probably can also create a variable as read-only in Moose and see where its been changed, but this module is without Moose support.

SUBROUTINES/METHODS

Trace

Watch a reference for changes:

Trace( \$scalar, @OPTIONS );
Trace( \@array , @OPTIONS );
Trace( \@hash , @OPTIONS );
Trace( $complex_data , @OPTIONS );

Just a stack trace with no watching:

Trace( @OPTIONS );

Options:

-clone => 0,    # Disable auto tying after a Storable dclone.

-var => REF,    # Variable to watch.
REF             # Same as passing a reference.

-levels => NUM  # How many scope levels to show.
NUM             # Same as passing a decimal.

-raw => 1,      # Include Internal call like Moose,
                # and Class::MOP in a trace.
-NUM            # Same as passing negative number.

-message => STR # Message to use for a normal (non-
                # tie stack trace).
STR             # Same as passing anything else.

-methods => STR   # Monitors only specific methods.
-methods => [STR] #

_ProcessArgs

Allows calling Trace like:
Trace() and Trace(-levels => 1) to
mean the same.

AUTHOR

Tim Potapov, <tim.potapov at gmail.com>

BUGS

Please report any bugs or feature requests to https://github.com/poti1/data-trace/issues.

Currently only detect STORE operations. Expand this to also detect PUSH, POP, DELETE, etc.

TODO

Consider adding an option to have a warn message anytime a structure is FETCHed.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Data::Trace

You can also look for information at:

https://metacpan.org/pod/Data::Trace

https://github.com/poti1/data-trace

LICENSE AND COPYRIGHT

This software is Copyright (c) 2024 by Tim Potapov.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

data-trace's People

Contributors

szabgab avatar poti1 avatar simbabque avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

simbabque

data-trace's Issues

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.