line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Flux::Log; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Flux::Log::VERSION = '1.00'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: storage implemented as log. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
122025
|
use Moo; |
|
1
|
|
|
|
|
16738
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
extends 'Flux::File'; |
11
|
|
|
|
|
|
|
with 'Flux::Storage::Role::ClientList'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
140287
|
use Type::Params qw(validate); |
|
1
|
|
|
|
|
221085
|
|
|
1
|
|
|
|
|
8
|
|
14
|
1
|
|
|
1
|
|
193
|
use Types::Standard qw(Str Dict HashRef); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
656
|
use File::Basename qw(basename); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
95
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
448
|
use Flux::Log::In; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Flux::Log::Types qw(ClientName); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has '+reopen' => ( |
22
|
|
|
|
|
|
|
default => sub { 1 }, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub description { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
return "log: ".$self->file; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'client_dir' => ( |
31
|
|
|
|
|
|
|
is => 'lazy', |
32
|
|
|
|
|
|
|
isa => Str, |
33
|
|
|
|
|
|
|
default => sub { |
34
|
|
|
|
|
|
|
my $self = shift; |
35
|
|
|
|
|
|
|
my $dir = $self->file.".pos"; |
36
|
|
|
|
|
|
|
unless (-d $dir) { |
37
|
|
|
|
|
|
|
mkdir $dir or die "mkdir failed: $!"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
return $dir; |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub in { |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
my ($client_or_params) = validate(\@_, ClientName | Dict[pos => Str]); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
if (ref $client_or_params) { |
48
|
|
|
|
|
|
|
return Flux::Log::In->new({ |
49
|
|
|
|
|
|
|
log => $self->file, |
50
|
|
|
|
|
|
|
unrotate => $client_or_params, |
51
|
|
|
|
|
|
|
}); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
|
|
|
|
|
|
return Flux::Log::In->new({ |
56
|
|
|
|
|
|
|
log => $self->file, |
57
|
|
|
|
|
|
|
unrotate => { |
58
|
|
|
|
|
|
|
pos => $self->client_dir."/".$client_or_params |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
}); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub client_names { |
65
|
|
|
|
|
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
my @files = glob $self->client_dir.'/*'; |
67
|
|
|
|
|
|
|
return map { basename $_ } @files; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |