| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::Saftpresse::Plugin::Role::Tracking; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
387
|
use Moose::Role; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.5'; # VERSION |
|
6
|
|
|
|
|
|
|
# ABSTRACT: role for plugins to implement transaction tracking |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
3220
|
use Log::Saftpresse::Log4perl; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
67
|
|
|
9
|
1
|
|
|
1
|
|
298
|
use UUID; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub set_tracking_id { |
|
12
|
|
|
|
|
|
|
my ( $self, $by, $stash, $notes, $key ) = @_; |
|
13
|
|
|
|
|
|
|
if( ! defined $key ) { |
|
14
|
|
|
|
|
|
|
$key = $stash->{$by}; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
if( ! defined $key ) { return; } |
|
17
|
|
|
|
|
|
|
my $id = $stash->{'tracking_id'}; |
|
18
|
|
|
|
|
|
|
if( ! defined $id ) { return; } |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$notes->set("tracking-$by-$key", $id); |
|
21
|
|
|
|
|
|
|
$log->debug("assigned existing tracking_id for $by-$key"); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get_tracking_id { |
|
27
|
|
|
|
|
|
|
my ( $self, $by, $stash, $notes, $key ) = @_; |
|
28
|
|
|
|
|
|
|
if( ! defined $key ) { |
|
29
|
|
|
|
|
|
|
$key = $stash->{$by}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
if( ! defined $key ) { return; } |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $id = $notes->get("tracking-$by-$key"); |
|
34
|
|
|
|
|
|
|
if( defined $id ) { |
|
35
|
|
|
|
|
|
|
$stash->{'tracking_id'} = $id; |
|
36
|
|
|
|
|
|
|
$log->debug("found existing tracking_id found for $by-$key"); |
|
37
|
|
|
|
|
|
|
} else { |
|
38
|
|
|
|
|
|
|
$log->debug("no tracking_id found for $by-$key"); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub clear_tracking_id { |
|
45
|
|
|
|
|
|
|
my ( $self, $by, $stash, $notes ) = @_; |
|
46
|
|
|
|
|
|
|
my $key = $stash->{$by}; |
|
47
|
|
|
|
|
|
|
if( ! defined $key ) { return; } |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$notes->remove("tracking-$by-$key"); |
|
50
|
|
|
|
|
|
|
$log->debug("cleared tracking_id for $by-$key"); |
|
51
|
|
|
|
|
|
|
return; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new_tracking_id { |
|
55
|
|
|
|
|
|
|
my ( $self, $stash, $notes ) = @_; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
if( defined $stash->{'pid'} ) { |
|
58
|
|
|
|
|
|
|
# rt.cpan.org #114390 |
|
59
|
|
|
|
|
|
|
# requires UUID >=0.06: |
|
60
|
|
|
|
|
|
|
# my $id = UUID::uuid; |
|
61
|
|
|
|
|
|
|
# this will work with UUID < 0.06: |
|
62
|
|
|
|
|
|
|
my ( $uuid, $id ); |
|
63
|
|
|
|
|
|
|
UUID::generate( $uuid ); UUID::unparse( $uuid, $id ); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$stash->{'tracking_id'} = $id; |
|
66
|
|
|
|
|
|
|
$notes->set('tracking-pid-'.$stash->{'pid'}, $id); |
|
67
|
|
|
|
|
|
|
$log->debug('generated tracking_id for pid-'.$stash->{'pid'}); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=pod |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=encoding UTF-8 |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Log::Saftpresse::Plugin::Role::Tracking - role for plugins to implement transaction tracking |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
version 1.5 |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This is free software, licensed under: |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |