Merge branch 'master' of github.com:dpavlin/angular-mojolicious
[angular-mojolicious.git] / couchdb-trigger.pl
index 77fa41c..1724b67 100755 (executable)
@@ -25,6 +25,8 @@ my ( $url, $trigger_path ) = @ARGV;
 $url          ||= 'http://localhost:5984/monitor';
 $trigger_path ||= 'trigger/shell.pm' ;
 
+our $database = $1 if $url =~ m{/(\w+)/?$};
+
 sub commit { warn "# commit ignored\n"; }
 require $trigger_path if -e $trigger_path;
 
@@ -81,7 +83,7 @@ while( ! $error ) {
                                                                if ( $tx->res->code == 409 ) {
                                                                        info "TRIGGER ABORTED started on another worker? ", $tx->error;
                                                                } else {
-                                                                       info "ERROR ", $tx->error;
+                                                                       info "ERROR $url/$id ", $tx->error;
                                                                }
                                                        } else {
                                                                my $res = $tx->res->json;
@@ -95,7 +97,7 @@ while( ! $error ) {
                                                                $client->put( "$url/$id" => $json->encode( $change->{doc} ) => sub {
                                                                        my ($client,$tx) = @_;
                                                                        if ($tx->error) {
-                                                                               info "ERROR", $tx->error;
+                                                                               info "ERROR $url/$id", $tx->error;
                                                                        } else {
                                                                                my $res = $tx->res->json;
                                                                                $change->{doc}->{_rev} = $res->{rev};