[Israel.pm] Access control/usage log for a package

Gaal Yahas gaal at forum2.org
Mon Oct 23 22:08:38 PDT 2006

On Tue, Oct 24, 2006 at 01:27:16AM +0200, Shmuel Fomberg wrote:
> I am looking at making an access logging tool for a package.
> Meaning that I want to log every subroutine call for this package and in
> the package.
> My idea is to iterate on the symbol table of the package, and to put an
> anonymous function
> Instead of every function. (that calls that function, after logging the
> access)

Wrapping every function is certainly one way to do it, but if you use
AOP you get nice declarative syntax and someone else to do the dirty
work for you:


The greatest thing about AOP is that the intrusion on your existing code
is minimal: you define what you want to do for a certain purpose (logging,
invariant assertion, security) in one place. Ran is the maintainer of
that module and has given a great talk on it in YAPC a few years back.

> Do you have better idea?
> Any idea how can I log variable access?

If you have an opportunity to tie some of them, try that. If you want
lexicals, it becomes much harder.

Do you need this stuff for debugging or for production use? Look into
the various trace modes of the debugger, they might do the job for you

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list