Modernize LC usage
[dbsrgits/DBIx-Class-DeploymentHandler.git] / lib / DBIx / Class / DeploymentHandler / Logger.pm
CommitLineData
4355e4fb 1package DBIx::Class::DeploymentHandler::Logger;
2
3use warnings;
4use strict;
5
6use parent 'Log::Contextual::WarnLogger';
7
8# trace works the way we want it already
9
10# sub is_trace { $_[0]->next::method }
11sub is_debug { $_[0]->is_trace || $_[0]->next::method }
12sub is_info { $_[0]->is_debug || $_[0]->next::method }
13
14sub is_warn {
15 my $orig = $_[0]->next::method;
16 return undef if defined $orig && !$orig;
17 return $_[0]->is_info || 1
18}
19
20sub is_error {
21 my $orig = $_[0]->next::method;
22 return undef if defined $orig && !$orig;
23 return $_[0]->is_warn || 1
24}
25
26sub is_fatal {
27 my $orig = $_[0]->next::method;
28 return undef if defined $orig && !$orig;
29 return $_[0]->is_error || 1
30}
31
f4075791 32sub _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
374a05c8 40sub new {
41 my ($self, $options, @rest) = @_;
42
43 $options ||= {};
44 $options->{env_prefix} ||= 'DBICDH';
45
46 $self->next::method($options, @rest)
47}
48
4355e4fb 491;