projects
/
clearscm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rsync Mikey & Kent
[clearscm.git]
/
lib
/
Speak.pm
diff --git
a/lib/Speak.pm
b/lib/Speak.pm
index
dd38346
..
9cb9441
100644
(file)
--- a/
lib/Speak.pm
+++ b/
lib/Speak.pm
@@
-83,7
+83,7
@@
Otherwise the text in the clipboard will be used.
=item $log
=item $log
-If provided, errors and messages will be logged to the logfile, otherwise
stdout
+If provided, errors and messages will be logged to the logfile, otherwise
to speak.log
=back
=back
@@
-103,13
+103,16
@@
Returns:
=cut
=cut
- if (-f "$FindBin::Bin/shh") {
- $msg .= ' [silent]';
- if ($log) {
- $log->msg($msg);
- } else {
- verbose $msg;
- } # if
+ $log = Logger->new(
+ path => '/var/local/log',
+ name => 'speak',
+ timestamped => 'yes',
+ append => 1,
+ ) unless $log;
+
+ if (-f "$FindBin::Bin/../data/shh") {
+ $msg .= ' [silent shh]';
+ $log->msg($msg);
return;
} # if
return;
} # if
@@
-120,40
+123,18
@@
Returns:
# Handle the case where $msg is a filehandle
$msg = <$msg> if ref $msg eq 'GLOB';
# Handle the case where $msg is a filehandle
$msg = <$msg> if ref $msg eq 'GLOB';
- # We can't have two speakers going at the same time so if we have an error
- # backoff a little and try again.
- my $attempts = 0;
- my $maxretries = 3;
-
- my ($status, @output);
-
# Log message to log file if $log was passed in.
# Log message to log file if $log was passed in.
- $log->msg($msg) if $log;
-
- while ($attempts++ < $maxretries) {
- ($status, @output) = Execute "/usr/local/bin/gt \"$msg\"";
-
- if ($status) {
- my $errmsg = "Unable to speak (Status: $status) - " . join "\n", @output;
+ $log->msg($msg);
- if ($log) {
- $log->err($errmsg);
- } else {
- error $errmsg;
- } # if
+ #$msg = quotemeta $msg;
+ $msg =~ s/\$/\\\$/g;
- sleep int rand 10;
- } else {
- return;
- } # if
- } # while
+ my ($status, @output) = Execute "/usr/local/bin/gt \"$msg\"";
- my $errmsg = 'Maximum retries exceeded - terminating';
+ if ($status) {
+ my $errmsg = "Unable to speak (Status: $status) - " . join "\n", @output;
- if ($log) {
- $log->err($errmsg, $status);
- } else {
- error $errmsg, $status;
+ $log->err($errmsg);
} # if
return;
} # if
return;