Schema::Graph - switch ugly use of Log4perl to an even uglier (but at least available...
Peter Rabbitson [Fri, 13 Feb 2009 07:41:51 +0000 (07:41 +0000)]
Lose l4p dependency

Build.PL
lib/SQL/Translator.pm
lib/SQL/Translator/Schema/Graph.pm

index 637c294..99f5516 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -23,7 +23,6 @@ my $builder = Module::Build->new(
     'Class::MakeMethods'       => 0,
     'Digest::SHA1'             => 2.00,
     'IO::Dir'                  => 0,
-    'Log::Log4perl'            => 0,
     'Parse::RecDescent'        => 1.94,
     'Pod::Usage'               => 0,
     'Class::Accessor::Fast'    => 0,
index 7b0dc58..918a15a 100644 (file)
@@ -31,7 +31,6 @@ $ERROR    = "";
 use Carp qw(carp);
 
 use Data::Dumper;
-use Class::Base;
 use File::Find;
 use File::Spec::Functions qw(catfile);
 use File::Basename qw(dirname);
index c3f61a7..897e535 100644 (file)
@@ -2,11 +2,11 @@ package SQL::Translator::Schema::Graph;
 
 use strict;
 
+use base 'Class::Base';
+
 use Data::Dumper;
 local $Data::Dumper::Maxdepth = 3;
 
-use Log::Log4perl qw(:easy);
-Log::Log4perl->easy_init($ERROR) unless Log::Log4perl->initialized();
 use SQL::Translator::Schema::Graph::Node;
 use SQL::Translator::Schema::Graph::Edge;
 use SQL::Translator::Schema::Graph::Port;
@@ -28,6 +28,9 @@ use Class::MakeMethods::Template::Hash (
   'number --counter' => [ qw( order ) ],
 );
 
+use vars qw/$DEBUG/;
+$DEBUG = 0 unless defined $DEBUG;
+
 sub init {
   my $self = shift;
 
@@ -173,7 +176,6 @@ sub init {
   }
 
   my $graph = $self; #hack
-  my $log   = Log::Log4perl->get_logger('SQL.Translator.Schema.Graph');
 
   #
   # create methods
@@ -208,8 +210,8 @@ sub init {
           $hyperedge->push_thatfield($edge->thisfield);
           $hyperedge->push_thatviafield($edge->thatfield);
         }
-        $log->debug($edge->thisfield->name);
-        $log->debug($edge->thatfield->name);
+        $self->debug($edge->thisfield->name);
+        $self->debug($edge->thatfield->name);
       }
 
       if ($hyperedge->count_thisnode == 1 and $hyperedge->count_thatnode == 1) {
@@ -222,18 +224,18 @@ sub init {
         $hyperedge->type('many2many');
       }
 
-      $log->debug($_) foreach sort keys %::SQL::Translator::Schema::Graph::HyperEdge::;
+      $self->debug($_) foreach sort keys %::SQL::Translator::Schema::Graph::HyperEdge::;
 
       #node_to won't always be defined b/c of multiple edges to a single other node
       if (defined($node_to)) {
-        $log->debug($node_from->name);
-        $log->debug($node_to->name);
+        $self->debug($node_from->name);
+        $self->debug($node_to->name);
 
         if (scalar($hyperedge->thisnode) > 1) {
-          $log->debug($hyperedge->type ." via ". $hyperedge->vianode->name);
+          $self->debug($hyperedge->type ." via ". $hyperedge->vianode->name);
           my $i = 0;
           foreach my $thisnode ( $hyperedge->thisnode ) {
-            $log->debug($thisnode->name .' '.
+            $self->debug($thisnode->name .' '.
                         $hyperedge->thisfield_index(0)->name .' -> '.
                         $hyperedge->thisviafield_index($i)->name .' '.
                         $hyperedge->vianode->name .' '.