File Coverage

blib/lib/VoiceXML/Client/Util.pm
Criterion Covered Total %
statement 9 16 56.2
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 0 2 0.0
total 12 26 46.1


line stmt bran cond sub pod time code
1             package VoiceXML::Client::Util;
2              
3 3     3   16 use strict;
  3         6  
  3         139  
4              
5              
6             =head1 COPYRIGHT AND LICENSE
7              
8            
9             Copyright (C) 2007,2008 by Pat Deegan.
10             All rights reserved
11             http://voicexml.psychogenic.com
12              
13             This library is released under the terms of the GNU GPL version 3, making it available only for
14             free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details).
15             Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to
16             acquire a distinct license for their application. This approach encourages the use of free software
17             while allowing for proprietary solutions that support further development.
18              
19              
20             This file is part of VoiceXML::Client.
21              
22            
23            
24             VoiceXML::Client is free software: you can redistribute it and/or modify
25             it under the terms of the GNU General Public License as published by
26             the Free Software Foundation, either version 3 of the License, or
27             (at your option) any later version.
28              
29             VoiceXML::Client is distributed in the hope that it will be useful,
30             but WITHOUT ANY WARRANTY; without even the implied warranty of
31             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32             GNU General Public License for more details.
33              
34             You should have received a copy of the GNU General Public License
35             along with VoiceXML::Client. If not, see .
36              
37              
38             =cut
39              
40 3         708 use vars qw{
41             $Die_on_error
42 3     3   17 };
  3         5  
43              
44             $Die_on_error = 0;
45              
46             sub error {
47 0     0 0 0 my $error = shift;
48 0         0 my $exit = shift; # optional
49            
50 0 0       0 $exit = 255
51             unless (defined $exit);
52            
53 0         0 my $date = localtime(time);
54            
55 0         0 print STDERR "$0 $date [$$] Fatal Error: $error\n";
56            
57 0 0       0 die $error
58             if ($Die_on_error);
59            
60 0         0 exit($exit);
61            
62             }
63              
64              
65              
66             sub log_msg {
67 6     6 0 15 my @msg = @_;
68            
69 6         1049 print STDERR "$0 [$$]: " , @msg, "\n";
70            
71 6         25 return;
72             }
73            
74             1;