From: Matt S Trout Date: Sun, 23 Oct 2011 15:02:15 +0000 (+0000) Subject: add a bit of debugging to the jsonrepl X-Git-Tag: v0.001001~40 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4d5b62fafd82ad425b83da43dee821448f2efd50;p=scpubgit%2FTak.git add a bit of debugging to the jsonrepl --- diff --git a/jsonrepl b/jsonrepl index 321beb0..4151567 100644 --- a/jsonrepl +++ b/jsonrepl @@ -6,11 +6,14 @@ use Eval::WithLexicals; use Data::Dumper::Concise; use IO::Handle; +our $DEBUG; + STDOUT->autoflush(1); my $eval = Eval::WithLexicals->new; sub out { + warn "sending: ".encode_json([ @_ ])."\n" if $DEBUG; print STDOUT encode_json([ @_ ])."\n" or die "Failed to print to STDOUT: $!"; } @@ -46,7 +49,10 @@ sub run_eval { out($code => { stdout => $output, stderr => $errors, return => $dumped_ret }); } +warn "starting\n" if $DEBUG; + while (my $line = ) { + warn "got: $line" if $DEBUG; my $data = eval { decode_json($line) }; if ($@) { out(MISTAKE => invalid_json => $@);