File Coverage

blib/lib/Catalyst/Plugin/LogDeep.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::LogDeep;
2              
3             # Created on: 2009-05-20 04:09:42
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   15600 use strict;
  1         1  
  1         30  
10 1     1   3 use warnings;
  1         1  
  1         21  
11 1     1   462 use version;
  1         1371  
  1         4  
12 1     1   57 use Carp;
  1         1  
  1         72  
13 1     1   4 use List::Util qw/ first /;
  1         1  
  1         82  
14 1     1   220 use Log::Deep;
  0            
  0            
15             use English qw/ -no_match_vars /;
16             use base qw/Exporter/;
17             use Class::C3::Adopt::NEXT -no_warn;
18              
19             our $VERSION = version->new('0.0.4');
20              
21             my $first = 1;
22             sub setup {
23             my $package = shift;
24             my $pkgname = ref $package || $package;
25              
26             if ($first) {
27             $first = 0;
28              
29             do {
30             no strict 'refs'; ## no critic
31             @{"${pkgname}::ISA"} = grep { $_ ne __PACKAGE__ } @{"${pkgname}::ISA"};
32             };
33              
34             my $cfg = $package->config->{'Plugin::LogDeep'} || {};
35              
36             $package->log( Log::Deep->new( %{ $cfg } ) );
37             $package->log->enable('debug');
38             $package->log->debug("How do I set the level?");
39             }
40              
41             $package->NEXT::setup(@_);
42             };
43              
44             1;
45              
46             __END__
47              
48             =head1 NAME
49              
50             Catalyst::Plugin::LogDeep - Sets up L<Log::Deep> for Catalyst logging
51              
52             =head1 VERSION
53              
54             This documentation refers to Catalyst::Plugin::LogDeep version 0.0.4.
55              
56             =head1 SYNOPSIS
57              
58             use Catalyst qw/ ... LogDeep/;
59              
60             __PACKAGE__->config(
61             'Plugin::LogDeep' => {
62             -name => __PACKAGE__,
63             -level => [ qw/debug warn error fatal/ ],
64             },
65             );
66              
67             $c->log->debug( { var => $variable }, 'This is the value of variable );
68             $c->log->error( 'You did not do something' );
69              
70             =head1 DESCRIPTION
71              
72             Allows Catalyst to use the L<Log::Deep> library for logging operations.
73              
74             The values set in the Plugin::LogDeep configuration item are passed directly
75             on to the L<Log::Deep> new method so look there for all the options for
76             configuration.
77              
78             Note: You currently need to tell add a call to $c->log->session in [every]
79             begin method if you want a per session log session id. Hopefully this wont
80             be required in future versions.
81              
82             =head1 SUBROUTINES/METHODS
83              
84             =head3 C<setup ()>
85              
86             Description: Sets up the catalyst application to use L<Log::Deep> as it's log
87             object.
88              
89             =head1 DIAGNOSTICS
90              
91             =head1 CONFIGURATION AND ENVIRONMENT
92              
93             =head1 DEPENDENCIES
94              
95             This module has only two dependencies C<Log::Deep> and L<Catalyst>
96              
97             =head1 INCOMPATIBILITIES
98              
99             =head1 BUGS AND LIMITATIONS
100              
101             There are no known bugs in this module.
102              
103             Please report problems to Ivan Wills (ivan.wills@gmail.com).
104              
105             Patches are welcome.
106              
107             =head1 AUTHOR
108              
109             Ivan Wills (ivan.wills@gmail.com)
110              
111             =head1 LICENSE AND COPYRIGHT
112              
113             Copyright (c) 2009 Ivan Wills (14 Mullion Close Hornsby Heights, NSW, Australia 2077).
114             All rights reserved.
115              
116             This module is free software; you can redistribute it and/or modify it under
117             the same terms as Perl itself. See L<perlartistic>. This program is
118             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
119             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
120             PARTICULAR PURPOSE.
121              
122             =cut