move common audit parts back into store
[pxelator] / lib / PXElator / CouchDB.pm
index efb15b5..1d1401b 100644 (file)
@@ -13,7 +13,6 @@ use Data::Structure::Util qw(unbless);
 use Scalar::Util qw/blessed/;
 use Storable qw/dclone/;
 use Carp qw/carp/;
-use POSIX;
 
 sub new {
        my ($class, $host, $port, $options) = @_;
@@ -115,45 +114,9 @@ sub post {
 
 our $audit = __PACKAGE__->new;
 
-sub audit {
-       my $data = pop @_;
-
-       my $url = join(' ', @_);
-       $url =~ s/\s+-\S+//g;   # remove command line options
-       $url =~ s/\W+/-/g;
-
-       my $time = time();
-
-       my @caller = caller(0);
-       $caller[3] = (caller(1))[3];
-       $caller[3] =~ s{^.+::}{}; # stip package name from sub
-       $data->{package} = {
-               time => $time,
-               name => $caller[0],
-               line => $caller[2],
-               caller  => $caller[3],
-       };
-
-       if ( $ENV{DEBUG} ) {
-
-               my $caller;
-               my $depth = 0;
-               while ( my @c = caller($depth) ) {
-                       push @$caller, [ @c ];
-                       $depth++;
-               }
-
-               $data->{caller} = $caller;
-
-       }
-
-#      carp 'audit ', dump($data);
-
-#      $time = int($time); # reduce granularity for url
-       $time = strftime("%Y-%m-%d.%H:%M:%S", localtime $time);
-       my $package = $caller[0];
-       $audit->put( "pxelator/$time.$package.$url", $data );
-
+sub _store_audit {
+       my ( $id, $data ) = @_;
+       $audit->put( "pxelator/$id", $data );
 }
 
 1;