Hector/Log.pm

filter: Statementstmt 100% 15 / 15 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 100% 30 / 30 CC 4 SCAR 10.0
CC
4
Cov
100%
log
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« Hector.pm ↑ Summary Hector/Response/NotModified.pm »
1 package PSGI::Hector::Log;
2  
3 =pod
4  
5 =head1 NAME
6  
7 PSGI::Hector::Log - Logging class
8  
9 =head1 SYNOPSIS
10  
11 =head1 DESCRIPTION
12  
13 =head1 METHODS
14  
15 =cut
16  
17 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 #########################################################
20  
21 =pod
22  
23 =head2 new($options)
24  
25 $log = PSGI::Hector::Log->new({
26 'debug' => 1
27 });
28  
29 Creates a new instance of the logging class
30  
31 =cut
32  
33 #########################################################
34 9 ▶sub new{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
35 9 my($class, $options) = @_;
36 my $self = {
37 9 '__debug' => $options->{'debug'}
38 };
39 9 bless $self, $class;
40 9 return $self;
41 }
42 #########################################################
43  
44 =pod
45  
46 =head2 log($message, $severity)
47  
48 $log->log('Just testing', 'info');
49  
50 Logs the provided string to STDERR with a prefixed severity.
51  
52 =cut
53  
54 ###########################################################
55 8 ▶sub log{ #a simple way to log a message to the apache error log
Subroutine log: called CC=4 SCAR=13.9
Pod documented
56 8 my($self, $message, $severity) = @_;
57 8 ▶ $severity = "" unless $severity;
Branch: 1 branch
BranchTrueFalseTotal
unless $severity 1 7 8
58 8 ▶ return if !$self->{'__debug'} and $severity eq 'debug'; #ignore debug messages when not in debug mode
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"__debug"} and $severity eq "debug" 1 7 8
Condition100%3/3
not $self->{"__debug"} and $severity eq "debug"
!ll&&!rl&&r
521
MC/DC100%2/2
not $self->{"__debug"} and $severity eq "debug"
not $self->{"__debug"} $severity eq "debug"
Truth table100%3/3
not(A) and B
A= not $self->{"__debug"}B= $severity eq "debug"
ABresult
0X0
100
111
59 7 print STDERR uc($severity) . " - " . $message . "\n";
60 }
61 #################################################
62  
63 =head1 Notes
64  
65 =head1 Author
66  
67 MacGyveR <dumb@cpan.org>
68  
69 Development questions, bug reports, and patches are welcome to the above address.
70  
71 =head1 See Also
72  
73 =head1 Copyright
74  
75 Copyright (c) 2019 MacGyveR. All rights reserved.
76  
77 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
78  
79 =cut
80  
81 ###############################################
82 6 return 1;
« Hector.pm ↑ Summary Hector/Response/NotModified.pm »