Modernize LC usage
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / Logger.pm
1 package DBIx::Class::DeploymentHandler::Logger;
2
3 use warnings;
4 use strict;
5
6 use parent 'Log::Contextual::WarnLogger';
7
8 # trace works the way we want it already
9
10 # sub is_trace {                  $_[0]->next::method }
11 sub is_debug { $_[0]->is_trace || $_[0]->next::method }
12 sub is_info  { $_[0]->is_debug || $_[0]->next::method }
13
14 sub is_warn  {
15    my $orig = $_[0]->next::method;
16    return undef if defined $orig && !$orig;
17    return $_[0]->is_info || 1
18 }
19
20 sub is_error {
21    my $orig = $_[0]->next::method;
22    return undef if defined $orig && !$orig;
23    return $_[0]->is_warn || 1
24 }
25
26 sub is_fatal {
27    my $orig = $_[0]->next::method;
28    return undef if defined $orig && !$orig;
29    return $_[0]->is_error || 1
30 }
31
32 sub _log {
33   my $self    = shift;
34   my $level   = shift;
35   my $message = join( "\n", @_ );
36   $message .= "\n" unless $message =~ /\n$/;
37   warn "[DBICDH] [$level] $message";
38 }
39
40 sub new {
41    my ($self, $options, @rest) = @_;
42
43    $options ||= {};
44    $options->{env_prefix} ||= 'DBICDH';
45
46    $self->next::method($options, @rest)
47 }
48
49 1;