Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.226.150.252
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : Debug.pm
package SQL::Translator::Role::Debug;
use Moo::Role;
use Sub::Quote qw(quote_sub);

has _DEBUG => (
    is => 'rw',
    accessor => 'debugging',
    init_arg => 'debugging',
    coerce => quote_sub(q{ $_[0] ? 1 : 0 }),
    lazy => 1,
    builder => 1,
);

sub _build__DEBUG {
    my ($self) = @_;
    my $class = ref $self;
    no strict 'refs';
    return ${"${class}::DEBUG"};
}

around debugging => sub {
    my ($orig, $self) = (shift, shift);

    # Emulate horrible Class::Base API
    unless (ref $self) {
        my $dbgref = do { no strict 'refs'; \${"${self}::DEBUG"} };
        $$dbgref = $_[0] if @_;
        return $$dbgref;
    }
    return $self->$orig(@_);
};

sub debug {
    my $self = shift;

    return unless $self->debugging;

    print STDERR '[', (ref $self || $self), '] ', @_, "\n";
}

1;
© 2025 GrazzMean