/[pxelator]/lib/PXElator/store.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/store.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 483 - (show annotations)
Sat Jan 23 18:58:18 2010 UTC (14 years, 3 months ago) by dpavlin
File size: 1074 byte(s)
move common audit parts back into store

1 package store;
2
3 use warnings;
4 use strict;
5
6 use POSIX;
7
8 use CouchDB;
9
10 =for MongoDB
11
12 use MongoDB;
13 my $conn = MongoDB::Connection->new;
14 my $db = $conn->get_database( 'pxelator' );
15 our $audit = $db->get_collection( 'audit' );
16
17 =cut
18
19 sub audit {
20 my $data = pop @_;
21
22 my $url = join(' ', @_);
23 $url =~ s/\s+-\S+//g; # remove command line options
24 $url =~ s/\W+/-/g;
25
26 my $time = time();
27
28 my @caller = caller(0);
29 $caller[3] = (caller(1))[3];
30 $caller[3] =~ s{^.+::}{}; # stip package name from sub
31 $data->{package} = {
32 time => $time,
33 name => $caller[0],
34 line => $caller[2],
35 caller => $caller[3],
36 };
37
38 if ( $ENV{DEBUG} ) {
39
40 my $caller;
41 my $depth = 0;
42 while ( my @c = caller($depth) ) {
43 push @$caller, [ @c ];
44 $depth++;
45 }
46
47 $data->{caller} = $caller;
48
49 }
50
51 # carp 'audit ', dump($data);
52
53 # $time = int($time); # reduce granularity for url
54 $time = strftime("%Y-%m-%d.%H:%M:%S", localtime $time);
55 my $package = $caller[0];
56
57 CouchDB::_store_audit( "$time.$package.$url" => $data );
58
59 # $data->{_id} = "$time.$package.$url"; $audit->insert( $data );
60 }
61
62
63 1;

  ViewVC Help
Powered by ViewVC 1.1.26