Salsa/Logs.pm

filter: Statementstmt 44.9% 22 / 49 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 36.0% 27 / 75 CC 9 SCAR 33.6
CC
9
Cov
34%
logs
56.0
debug
12.0
BEGIN
1.0
CRAP 28.9
« Salsa/Action/Subscribe.pm ↑ Summary Salsa.pm »
1 #
2 # Mail/Salsa/Logs.pm
3 # Last Modification: Wed Apr 6 16:13:12 WEST 2005
4 #
5 # Copyright (c) 2005 Henrique Dias <hdias@aesbuc.pt>. All rights reserved.
6 # This module is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
8 #
9 package Mail::Salsa::Logs;
10  
11 10 ▶use 5.008000;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 10 require Exporter;
16 10 ▶use AutoLoader qw(AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 10 ▶use Mail::Salsa::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 10 our @ISA = qw(Exporter);
20  
21 # Items to export into callers namespace by default. Note: do not export
22 # names by default without a very good reason. Use EXPORT_OK instead.
23 # Do not simply export all your public functions/methods/constants.
24  
25 # This allows declaration use Mail::Salsa::Logs ':all';
26 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
27 # will save memory.
28 10 our %EXPORT_TAGS = ( 'all' => [ qw() ] );
29  
30 10 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
31  
32 10 our @EXPORT = qw(&logs &debug);
33  
34 10 our $VERSION = '0.02';
35  
36 0 ▶sub logs {
Subroutine logs: not called CC=7 SCAR=40.3
Pod undocumented
37 0 my $self = shift;
38 0 my $string = shift;
39 0 ▶ my $type = shift || "error";
Condition0%0/2
shift() || 'error'
l!l
00
MC/DC0%0/1
shift() || 'error'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
40  
41 0 my ($name, $domain) = split(/\@/, $self->{'list'});
42 0 my $dir = join("/", $self->{'logs_dir'}, $domain, $name);
43 0 ▶ unless(-d $dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $dir) 0 0 0
44 0 Mail::Salsa::Utils::make_dir_rec($dir, 0755);
45 0 ▶ (-d $dir) or die("$!");
Branch: 1 branch
BranchTrueFalseTotal
-d $dir or die "$!" 0 0 0
46 }
47 0 my $today = Mail::Salsa::Utils::string_date();
48 0 ▶ $string .= "\n" unless($string =~ /\n+$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ /\n+$/ 0 0 0
49 0 ▶ if($string eq "error") {
Branch: 1 branch
BranchTrueFalseTotal
if ($string eq "error") 0 0 0
50 0 my $package = caller();
51 0 $string = "$package $string";
52 }
53 0 my $file = join("/", $dir, "$type\.log");
54 0 ▶ open(LOGS, ">>", $file) or die("$!");
Branch: 1 branch
BranchTrueFalseTotal
open LOGS, ">>", $file or die "$!" 0 0 0
55 0 print LOGS "$today $string";
56 0 close(LOGS);
57  
58 0 my $mode = 0600;
59 0 chmod($mode, $file);
60  
61 0 return();
62 }
63  
64 0 ▶sub debug {
Subroutine debug: not called CC=3 SCAR=24.8
Pod undocumented
65 0 my $self = shift;
66 0 my $string = shift;
67  
68 0 ▶ $string .= "\n" unless($string =~ /\n+$/);
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ /\n+$/ 0 0 0
69 0 ▶ open(DEBUG, ">>", "/tmp/salsa.debug") or die("$!");
Branch: 1 branch
BranchTrueFalseTotal
open DEBUG, ">>", "/tmp/salsa.debug" or die "$!" 0 0 0
70 0 print DEBUG $string;
71 0 close(DEBUG);
72  
73 0 return();
74 }
75  
76 # Preloaded methods go here.
77  
78 # Autoload methods go after =cut, and are processed by the autosplit program.
79  
80 10 1;
81 __END__
« Salsa/Action/Subscribe.pm ↑ Summary Salsa.pm »