Unfuck Catalyst::Plugin::Log::Dispatch
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Log.pm
index a74f614..a28c373 100644 (file)
@@ -4,7 +4,7 @@ use Moose;
 with 'MooseX::Emulate::Class::Accessor::Fast';
 
 use Data::Dump;
-use Class::MOP::Object ();
+use Class::MOP ();
 
 our %LEVELS = ();
 
@@ -15,7 +15,7 @@ has abort => (is => 'rw');
 {
     my @levels = qw[ debug info warn error fatal ];
 
-    my $meta = __PACKAGE__->Class::MOP::Object::meta();
+    my $meta = Class::MOP::get_metaclass_by_name(__PACKAGE__);
     for ( my $i = 0 ; $i < @levels ; $i++ ) {
 
         my $name  = $levels[$i];
@@ -101,8 +101,23 @@ sub _send_to_log {
     print STDERR @_;
 }
 
+# 5.7 compat code.
+# Alias _body to body, add a before modifier to warn..
+my $meta = __PACKAGE__->meta; # Calling meta method here fine as we happen at compile time.
+$meta->add_method('body', $meta->get_method('_body'));
+my %package_hash; # Only warn once per method, per package. 
+                  # I haven't provided a way to disable them, patches welcome.
+$meta->add_before_method_modifier('body', sub {
+    my $class = blessed(shift);
+    $package_hash{$class}++ || do {
+        warn("Class $class is calling the deprecated method Catalyst::Log->body method,\n"
+            . "this will be removed in Catalyst 5.81");
+    };
+});
+# End 5.70 backwards compatibility hacks.
+
 no Moose;
-__PACKAGE__->meta->make_immutable();
+__PACKAGE__->meta->make_immutable(inline_constructor => 0);
 
 1;