summaryrefslogtreecommitdiffstats
path: root/log.pl
diff options
context:
space:
mode:
Diffstat (limited to 'log.pl')
-rwxr-xr-xlog.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/log.pl b/log.pl
new file mode 100755
index 0000000..468d322
--- /dev/null
+++ b/log.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+
+use strict;
+use AnyEvent;
+use AnyEvent::Socket;
+use AnyEvent::Handle;
+
+my $log_socket = '/tmp/log.sock';
+
+my $cv = AnyEvent->condvar;
+
+tcp_connect 'unix/', $log_socket, sub {
+ my ($fh) = @_ or die "Unable to connect: $!";
+
+ my $h; $h = new AnyEvent::Handle
+ fh => $fh,
+ on_eof => sub { $h->destroy; $cv->send; },
+ on_error => sub { die("Connection closed."); };
+
+ while (<STDIN>) {
+ $h->push_write($_);
+ }
+
+ $h->push_shutdown;
+ $h->destroy;
+ $cv->send;
+};
+
+$cv->recv;