Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add logger role

  • Loading branch information...
commit 55d493cc6af789a1caa97b907599c7afbce9628a 1 parent fd50678
@jberger authored
Showing with 34 additions and 0 deletions.
  1. +34 −0 lib/Moodule/Build/Role/Logger.pm
View
34 lib/Moodule/Build/Role/Logger.pm
@@ -0,0 +1,34 @@
+package Moodule::Build::Role::Logger;
+
+use Moo::Role;
+
+has 'quiet' => ( is => 'rw' );
+has 'verbose' => ( is => 'rw' );
+has 'debug' => ( is => 'rw' );
+
+sub log_info {
+ my $self = shift;
+ print @_ if ref($self) && ( $self->verbose || ! $self->quiet );
+}
+sub log_verbose {
+ my $self = shift;
+ print @_ if ref($self) && $self->verbose;
+}
+sub log_debug {
+ my $self = shift;
+ print @_ if ref($self) && $self->debug;
+}
+
+sub log_warn {
+ # Try to make our call stack invisible
+ shift;
+ if (@_ and $_[-1] !~ /\n$/) {
+ my (undef, $file, $line) = caller();
+ warn @_, " at $file line $line.\n";
+ } else {
+ warn @_;
+ }
+}
+
+1;
+
Please sign in to comment.
Something went wrong with that request. Please try again.