line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
39
|
|
|
39
|
|
19475
|
use strict; |
|
39
|
|
|
|
|
92
|
|
|
39
|
|
|
|
|
1196
|
|
2
|
39
|
|
|
39
|
|
217
|
use warnings; |
|
39
|
|
|
|
|
97
|
|
|
39
|
|
|
|
|
933
|
|
3
|
39
|
|
|
39
|
|
684
|
use 5.024; |
|
39
|
|
|
|
|
132
|
|
4
|
|
|
|
|
|
|
|
5
|
39
|
|
|
39
|
|
208
|
use feature qw /postderef signatures/; |
|
39
|
|
|
|
|
83
|
|
|
39
|
|
|
|
|
3426
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Moose::Role; |
8
|
39
|
|
|
39
|
|
277
|
|
|
39
|
|
|
|
|
103
|
|
|
39
|
|
|
|
|
269
|
|
9
|
|
|
|
|
|
|
no warnings 'experimental'; |
10
|
39
|
|
|
39
|
|
206043
|
use Path::Tiny 0.108; |
|
39
|
|
|
|
|
92
|
|
|
39
|
|
|
|
|
2056
|
|
11
|
39
|
|
|
39
|
|
273
|
|
|
39
|
|
|
|
|
905
|
|
|
39
|
|
|
|
|
29228
|
|
12
|
|
|
|
|
|
|
our $VERSION='2.02'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Vote::Count::Log |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION 2.02 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# ABSTRACT: Logging for Vote::Count. Toolkit for vote counting. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 Vote::Count Logging Methods |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 LogTo |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Sets a path and Naming pattern for writing logs with the WriteLogs method. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
'LogTo' => '/logging_path/election_name' |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
LogTo will not create a new directory if the directory does not exist. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The default log location is '/tmp/votecount'. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 LogPath |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Specifies a Path to the Log Files, unlike LogTo, LogPath will create the Path if it does not exist. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 LogBaseName |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Sets the Base portion of the logfile names, but only if LogPath is specified. The default value is votecount. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 WriteLog |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Write the logs appending '.brief', '.full', and '.debug' for the three logs where brief is a summary written with the logt (log terse) method, the full transcript log written with logv, and finally the debug log written with logd. Each higher log level captures all events of the lower log levels. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Logged events are not written until WriteLog is called. A fatal runtime error, would prevent execution of a writelog at the end of the script. If you need to see the logs when your program is crashing, set the Debug Flag to write the events as warnings to STDERR while the script is running. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 Logging Events |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
When logging from your methods, use logt for events that produce a summary, use logv for events that should be in the full transcript such as round counts, and finally debug is for events that may be helpful in debugging but which should not be in the transcript. Events written to logt will be included in the verbose log and all events in the verbose log will be in the debug log. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
The logx methods will return the current log if called without any message to log. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 logt |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Record message to the terse (.brief) log. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 logv |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Record message to the more verbose (.full) log. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 logd |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Record message to the debug (.debug) log. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 Debug Flag |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
When the debug flag is logx methods will also emit the event as a warning (STDERR). The Debug Flag defaults to off (0), but can be explicitly set via the new method of a Vote::Count object, or toggled by passing 0 or 1 via the Debug Method. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$Election->Debug(1); # turn debug on |
73
|
|
|
|
|
|
|
is( $Election->Action(), $expected, 'Thing Im debugging'); |
74
|
|
|
|
|
|
|
$Election->Debug(0); # turn debug off |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has 'LogTo' => ( |
79
|
|
|
|
|
|
|
is => 'lazy', |
80
|
|
|
|
|
|
|
is => 'rw', |
81
|
|
|
|
|
|
|
isa => 'Str', |
82
|
|
|
|
|
|
|
builder => '_logsetup', |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has 'LogPath' => ( |
86
|
|
|
|
|
|
|
is => 'rw', |
87
|
|
|
|
|
|
|
isa => 'Str', |
88
|
|
|
|
|
|
|
default => '/tmp', |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has 'LogBaseName' => ( |
92
|
|
|
|
|
|
|
is => 'rw', |
93
|
|
|
|
|
|
|
isa => 'Str', |
94
|
|
|
|
|
|
|
default => 'votecount' |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has 'Debug' => ( |
98
|
|
|
|
|
|
|
default => 0, |
99
|
|
|
|
|
|
|
is => 'rw', |
100
|
|
|
|
|
|
|
isa => 'Bool', |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
my $pathBase = $self->{'LogPath'} || '/tmp'; |
104
|
158
|
|
|
158
|
|
73895
|
$pathBase =~ s/\/$|\\$//; # trim \ or / from end. |
|
158
|
|
|
|
|
276
|
|
|
158
|
|
|
|
|
245
|
|
105
|
158
|
|
100
|
|
|
568
|
unless ( stat $pathBase ) { |
106
|
158
|
|
|
|
|
884
|
path($pathBase)->mkpath(); |
107
|
158
|
100
|
|
|
|
2820
|
} |
108
|
1
|
|
|
|
|
7
|
my $baseName = $self->{'LogBaseName'} || 'votecount'; |
109
|
|
|
|
|
|
|
return "$pathBase/$baseName"; |
110
|
158
|
|
100
|
|
|
1078
|
} |
111
|
158
|
|
|
|
|
4602
|
|
112
|
|
|
|
|
|
|
my $self = shift @_; |
113
|
|
|
|
|
|
|
return $self->{'LogT'} unless (@_); |
114
|
|
|
|
|
|
|
my $msg = join( "\n", @_ ) . "\n"; |
115
|
639
|
|
|
639
|
1
|
11367
|
$self->{'LogT'} .= $msg; |
116
|
639
|
100
|
|
|
|
1612
|
$self->{'LogV'} .= $msg; |
117
|
613
|
|
|
|
|
1727
|
$self->logd(@_); |
118
|
613
|
|
|
|
|
1617
|
} |
119
|
613
|
|
|
|
|
1595
|
|
120
|
613
|
|
|
|
|
1604
|
my $self = shift @_; |
121
|
|
|
|
|
|
|
return $self->{'LogV'} unless (@_); |
122
|
|
|
|
|
|
|
my $msg = join( "\n", @_ ) . "\n"; |
123
|
|
|
|
|
|
|
$self->{'LogV'} .= $msg; |
124
|
6749
|
|
|
6749
|
1
|
17482
|
$self->logd(@_); |
125
|
6749
|
100
|
|
|
|
12258
|
} |
126
|
6719
|
|
|
|
|
14673
|
|
127
|
6719
|
|
|
|
|
13726
|
my $self = shift @_; |
128
|
6719
|
|
|
|
|
12484
|
return $self->{'LogD'} unless (@_); |
129
|
|
|
|
|
|
|
my @args = (@_); |
130
|
|
|
|
|
|
|
# since ops are seqential and fast logging event times |
131
|
|
|
|
|
|
|
# clutters the debug log. |
132
|
7426
|
|
|
7426
|
1
|
18998
|
# unshift @args, localtime->date . ' ' . localtime->time; |
133
|
7426
|
100
|
|
|
|
13540
|
my $msg = join( "\n", @args ) . "\n"; |
134
|
7402
|
|
|
|
|
13393
|
$self->{'LogD'} .= $msg; |
135
|
|
|
|
|
|
|
warn $msg if $self->Debug(); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
7402
|
|
|
|
|
14326
|
my $self = shift @_; |
139
|
7402
|
|
|
|
|
13996
|
my $logroot = $self->LogTo(); |
140
|
7402
|
100
|
|
|
|
192309
|
path("$logroot.brief")->spew( $self->logt() ); |
141
|
|
|
|
|
|
|
path("$logroot.full")->spew( $self->logv() ); |
142
|
|
|
|
|
|
|
path("$logroot.debug")->spew( $self->logd() ); |
143
|
|
|
|
|
|
|
} |
144
|
14
|
|
|
14
|
1
|
88
|
|
145
|
14
|
|
|
|
|
424
|
1; |
146
|
14
|
|
|
|
|
77
|
|
147
|
14
|
|
|
|
|
7374
|
#FOOTER |
148
|
14
|
|
|
|
|
6086
|
|
149
|
|
|
|
|
|
|
=pod |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
BUG TRACKER |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L<https://github.com/brainbuz/Vote-Count/issues> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
AUTHOR |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
John Karr (BRAINBUZ) brainbuz@cpan.org |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
CONTRIBUTORS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Copyright 2019-2021 by John Karr (BRAINBUZ) brainbuz@cpan.org. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
LICENSE |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This module is released under the GNU Public License Version 3. See license file for details. For more information on this license visit L<http://fsf.org>. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
SUPPORT |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This software is provided as is, per the terms of the GNU Public License. Professional support and customisation services are available from the author. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|