line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Saftpresse::Plugin::Role::Tracking; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
490
|
use Moose::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.4'; # VERSION |
6
|
|
|
|
|
|
|
# ABSTRACT: role for plugins to implement transaction tracking |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
3405
|
use Log::Saftpresse::Log4perl; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
88
|
|
9
|
1
|
|
|
1
|
|
310
|
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
|
|
|
|
|
|
|
my $id = UUID::uuid; |
59
|
|
|
|
|
|
|
$stash->{'tracking_id'} = $id; |
60
|
|
|
|
|
|
|
$notes->set('tracking-pid-'.$stash->{'pid'}, $id); |
61
|
|
|
|
|
|
|
$log->debug('generated tracking_id for pid-'.$stash->{'pid'}); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=encoding UTF-8 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Log::Saftpresse::Plugin::Role::Tracking - role for plugins to implement transaction tracking |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
version 1.4 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is free software, licensed under: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |