| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ixchel::functions::status; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
139696
|
use 5.006; |
|
|
8
|
|
|
|
|
29
|
|
|
4
|
8
|
|
|
8
|
|
44
|
use strict; |
|
|
8
|
|
|
|
|
30
|
|
|
|
8
|
|
|
|
|
213
|
|
|
5
|
8
|
|
|
8
|
|
61
|
use warnings; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
489
|
|
|
6
|
8
|
|
|
8
|
|
743
|
use File::Slurp; |
|
|
8
|
|
|
|
|
237790
|
|
|
|
8
|
|
|
|
|
770
|
|
|
7
|
8
|
|
|
8
|
|
66
|
use Exporter 'import'; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
2279
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw(status); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Ixchel::functions::status - Helper function for creating status lines. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.0.1 |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Ixchel::functions::status; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$status=$status.status(type=>'Foo', error=>0, status=>'Some status...', no_print=>0); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This creates a status text line in the format below... |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
'[' . $timestamp . '] [' . $opts{type} . ', ' . $opts{error} . '] ' . $opts{status}."\n"; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$timestamp is created as below. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); |
|
35
|
|
|
|
|
|
|
my $timestamp = sprintf( "%04d-%02d-%02dT%02d:%02d:%02d", $year + 1900, $mon + 1, $mday, $hour, $min, $sec ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 Functions |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 status |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Creates a new status line for use with functions. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head3 opts |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head4 type |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
The type to use. If not set it is set to 'undef'. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head4 status |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The new status. If undef '' is just returned. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head4 error |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
If it is an error or not. Defaults to 0. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head4 no_print |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
If it should print it or not. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub status { |
|
64
|
0
|
|
|
0
|
1
|
|
my (%opts) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
if ( !defined( $opts{status} ) ) { |
|
67
|
0
|
|
|
|
|
|
return ''; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
0
|
|
|
|
|
|
chomp( $opts{status} ); |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ( !defined( $opts{error} ) ) { |
|
72
|
0
|
|
|
|
|
|
$opts{error} = 0; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
if ( !defined( $opts{type} ) ) { |
|
76
|
0
|
|
|
|
|
|
$opts{type} = 'undef'; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); |
|
80
|
0
|
|
|
|
|
|
my $timestamp = sprintf( "%04d-%02d-%02dT%02d:%02d:%02d", $year + 1900, $mon + 1, $mday, $hour, $min, $sec ); |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my $status = '[' . $timestamp . '] [' . $opts{type} . ', ' . $opts{error} . '] ' . $opts{status} . "\n"; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if ( !$opts{no_print} ) { |
|
85
|
0
|
|
|
|
|
|
print $status; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $status; |
|
89
|
|
|
|
|
|
|
} ## end sub status |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |