convert to unobtrusive Dist::Zilla
[p5sagit/Log-Contextual.git] / lib / Log / Contextual / Easy / Default.pm
CommitLineData
afbb27d5 1package Log::Contextual::Easy::Default;
436c4b82 2
dc4fd4b0 3# ABSTRACT: Import all logging methods with WarnLogger as default
4
5use strict;
6use warnings;
7
436c4b82 8use base 'Log::Contextual';
9
10sub arg_default_logger {
11 if ($_[1]) {
12 return $_[1];
13 } else {
14 require Log::Contextual::WarnLogger;
15 my $package = uc(caller(3));
16 $package =~ s/::/_/g;
17 return Log::Contextual::WarnLogger->new({env_prefix => $package});
18 }
19}
20
21sub default_import { qw(:dlog :log ) }
22
231;
24
25__END__
26
436c4b82 27=head1 SYNOPSIS
28
29In your module:
30
31 package My::Module;
afbb27d5 32 use Log::Contextual::Easy::Default;
436c4b82 33
34 log_debug { "your message" };
35 Dlog_trace { $_ } @vars;
36
37In your program:
38
39 use My::Module;
40
41 # enable warnings
42 $ENV{MY_MODULE_UPTO}="TRACE";
43
44 # or use a specific logger with set_logger / with_logger
45
46=head1 DESCRIPTION
47
48By default, this module enables a L<Log::Contextual::WarnLogger>
49with C<env_prefix> based on the module's name that uses
50Log::Contextual::Easy. The logging levels are set to C<trace> C<debug>,
51C<info>, C<warn>, C<error>, and C<fatal> (in this order) and all
52logging functions (L<log_...|Log::Contextual/"log_$level">,
53L<logS_...|Log::Contextual/"logS_$level">,
54L<Dlog_...|Log::Contextual/"Dlog_$level">, and
55L<Dlog...|Log::Contextual/"DlogS_$level">) are exported.
56
92dc8d35 57For what C<::Default> implies, see L<Log::Contextual/-default_logger>.
58
436c4b82 59=head1 SEE ALSO
60
61=over 4
62
92dc8d35 63=item L<Log::Contextual::Easy::Package>
64
436c4b82 65=back