NAME

Medusa - Subroutine auditing via attributes

VERSION

Version 0.04

SYNOPSIS

package MyApp;
use Medusa;

sub process_data :Audit {
    my ($self, $data) = @_;
    # ... process data ...
    return $result;
}

# With custom configuration
package MyApp;
use Medusa (
    LOG_LEVEL => 'info',
    LOG_FILE  => 'my_audit.log',
);

sub important_action :Audit {
    my ($self, @args) = @_;
    # This subroutine's calls and returns will be logged
    return @results;
}

sub error_action :Audit(error) {
    ...
}

DESCRIPTION

Medusa provides a simple mechanism to add auditing to subroutines using Perl attributes. By adding the :Audit attribute to a subroutine, Medusa will automatically log when the subroutine is called (including its arguments) and what it returns.

This is useful for debugging, compliance auditing, or tracking the flow of data through your application.

USAGE

To use Medusa, simply use the module in your package and add the :Audit attribute to any subroutines you want to audit:

package MyModule;
use Medusa;

sub my_method :Audit {
    my ($self, $arg1, $arg2) = @_;
    return $arg1 + $arg2;
}

When my_method is called, Medusa will log:

  • The subroutine name and arguments passed to it

  • The return value(s) when the subroutine completes

CONFIGURATION

Medusa accepts the following configuration options during import:

LOGGER

The logger class to use. Defaults to Medusa::Logger.

use Medusa ( LOGGER => 'My::Custom::Logger' );
LOG_LEVEL

The log level to use. Defaults to debug. Available levels are determined by your logger class (error, info, debug).

use Medusa ( LOG_LEVEL => 'info' );
LOG_FILE

The file to write audit logs to. Defaults to audit.log.

use Medusa ( LOG_FILE => '/var/log/myapp/audit.log' );

CUSTOM LOGGERS

You can provide your own logger class by setting the LOGGER option. Your logger class must implement:

  • new(%args) - Constructor that accepts a file argument

  • Log level methods (error, info, debug) that accept a message string

AUTHOR

LNATION <email@lnation.org>

BUGS

Please report any bugs or feature requests to bug-medusa at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Medusa. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

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

perldoc Medusa

You can also look for information at:

SEE ALSO

Medusa::Logger, attributes

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION <email@lnation.org>.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)