line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ftn-log |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package FTN::Log; |
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
60101
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
110
|
|
6
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
124
|
|
7
|
3
|
|
|
3
|
|
17
|
use Carp qw( croak ); |
|
3
|
|
|
|
|
16
|
|
|
3
|
|
|
|
|
202
|
|
8
|
3
|
|
|
3
|
|
14
|
use vars qw($VERSION @ISA @EXPORT_OK); |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
1111
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
FTN::Log - Perl extension for logging Fidonet Technology Networks (FTN) related processing. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
VERSION 0.10 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$VERSION = '0.10'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require Exporter; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
25
|
|
|
|
|
|
|
@EXPORT_OK = qw(&logging |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 FUNCTIONS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 logging |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Syntax: logging($log_file, $id, $text); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
An FTN compatible Logging subroutine, where: |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item $log_file |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Filename and path to the log file. Can also be STDOUT or STDERR. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item $id |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Short string than can identify which program is doing the logging. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item $text |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
A string containing what is being logged. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub logging { |
56
|
1
|
|
|
1
|
1
|
120
|
my($log_file, $id, $log_text) = @_; |
57
|
1
|
|
|
|
|
3
|
my (@x, $fh); |
58
|
1
|
|
|
|
|
5
|
my @month = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', |
59
|
|
|
|
|
|
|
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# write to the log file |
62
|
1
|
50
|
|
|
|
7
|
if($log_file eq "stdout") { |
|
|
50
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
0
|
open( $fh, q{>}, *STDOUT ) || croak "Cannot open STDOUT for logging."; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif($log_file eq "stderr") { |
66
|
0
|
0
|
|
|
|
0
|
open( $fh, q{>}, *STDERR ) || croak "Cannot open STDERR for logging."; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
1
|
50
|
|
|
|
59
|
open( $fh, q{>>}, $log_file ) || croak "Cannot open $log_file for logging."; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
163
|
@x = localtime; |
73
|
1
|
|
|
|
|
27
|
printf $fh "%s %02d %02d:%02d:%02d ", |
74
|
|
|
|
|
|
|
$month[$x[4]], $x[3], $x[2], $x[1], $x[0]; |
75
|
1
|
|
|
|
|
5
|
print $fh "$id $log_text\n"; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
51
|
close($fh); |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
12
|
return 1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Robert James Clay, C<< >> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 BUGS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
90
|
|
|
|
|
|
|
the web interface at L. I will be |
91
|
|
|
|
|
|
|
notified, and then you'll automatically be notified of progress on your bug as I make changes. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SUPPORT |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
perldoc FTN::Log |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
You can also look for information at: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over 4 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * CPAN Ratings |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * Search CPAN |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=back |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Copyright 2001-2012 Robert James Clay, all rights reserved. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
126
|
|
|
|
|
|
|
under the same terms as Perl itself. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SEE ALSO |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; # End of FTN::Log |