convert to Dist::Zilla
[gitmo/MooseX-Runnable.git] / lib / MooseX / Runnable / Invocation / Plugin / Debug.pm
index 00db16a..9e3fd6c 100644 (file)
@@ -1,6 +1,10 @@
 package MooseX::Runnable::Invocation::Plugin::Debug;
+# ABSTRACT: print debugging information
+
 use Moose::Role;
 
+with 'MooseX::Runnable::Invocation::Plugin::Role::CmdlineArgs';
+
 # this is an example to cargo-cult, rather than a useful feature :)
 has 'debug_prefix' => (
     is       => 'ro',
@@ -22,6 +26,11 @@ sub _build_initargs_from_cmdline {
     return;
 }
 
+sub _debug_message {
+    my ($self, @msg) = @_;
+    print {*STDERR} $self->debug_prefix, "[$$] ", @msg, "\n";
+}
+
 for my $method (qw{
     load_class apply_scheme validate_class
     create_instance start_application
@@ -31,13 +40,30 @@ for my $method (qw{
     before $method => sub {
         my ($self, @args) = @_;
         my $args = join ', ', @args;
-        print $self->debug_prefix, "Calling $method($args)\n";
+        $self->_debug_message("Calling $method($args)");
     };
 
     after $method => sub {
         my $self = shift;
-        print $self->debug_prefix, "Returning from $method\n";
+        $self->_debug_message("Returning from $method");
     };
 }
 
 1;
+
+__END__
+
+=pod
+
+=head1 DESCRIPTION
+
+This is an example plugin, showing how you could write your own.  It
+prints a message for each stage of the "run" process.  It is also used
+by other plugins to determine whether or not to print debugging
+messages.
+
+=head1 SEE ALSO
+
+L<MooseX::Runnable>
+
+=cut