line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Mail/Salsa/Logs.pm |
3
|
|
|
|
|
|
|
# Last Modification: Wed Apr 6 16:13:12 WEST 2005 |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright (c) 2005 Henrique Dias . 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
|
|
|
10
|
|
28367
|
use 5.008000; |
|
10
|
|
|
|
|
41
|
|
|
10
|
|
|
|
|
391
|
|
12
|
10
|
|
|
10
|
|
53
|
use strict; |
|
10
|
|
|
|
|
33
|
|
|
10
|
|
|
|
|
281
|
|
13
|
10
|
|
|
10
|
|
53
|
use warnings; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
373
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Exporter; |
16
|
10
|
|
|
10
|
|
5592
|
use AutoLoader qw(AUTOLOAD); |
|
10
|
|
|
|
|
10223
|
|
|
10
|
|
|
|
|
59
|
|
17
|
10
|
|
|
10
|
|
2789
|
use Mail::Salsa::Utils; |
|
10
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
6565
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw() ] ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our @EXPORT = qw(&logs &debug); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub logs { |
37
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
my $string = shift; |
39
|
0
|
|
0
|
|
|
|
my $type = shift || "error"; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my ($name, $domain) = split(/\@/, $self->{'list'}); |
42
|
0
|
|
|
|
|
|
my $dir = join("/", $self->{'logs_dir'}, $domain, $name); |
43
|
0
|
0
|
|
|
|
|
unless(-d $dir) { |
44
|
0
|
|
|
|
|
|
Mail::Salsa::Utils::make_dir_rec($dir, 0755); |
45
|
0
|
0
|
|
|
|
|
(-d $dir) or die("$!"); |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
my $today = Mail::Salsa::Utils::string_date(); |
48
|
0
|
0
|
|
|
|
|
$string .= "\n" unless($string =~ /\n+$/); |
49
|
0
|
0
|
|
|
|
|
if($string eq "error") { |
50
|
0
|
|
|
|
|
|
my $package = caller(); |
51
|
0
|
|
|
|
|
|
$string = "$package $string"; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
my $file = join("/", $dir, "$type\.log"); |
54
|
0
|
0
|
|
|
|
|
open(LOGS, ">>", $file) or die("$!"); |
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
|
|
|
|
|
|
|
sub debug { |
65
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
my $string = shift; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
$string .= "\n" unless($string =~ /\n+$/); |
69
|
0
|
0
|
|
|
|
|
open(DEBUG, ">>", "/tmp/salsa.debug") or die("$!"); |
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
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
__END__ |