| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Log.pm - Keep trace of modifics of table |
|
4
|
|
|
|
|
|
|
# Use: log('sql command','user','name_of_file') |
|
5
|
|
|
|
|
|
|
# (c) Copyright 2000 Costantino Giuseppe |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
8
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
9
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
10
|
|
|
|
|
|
|
# any later version. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
18
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
|
19
|
|
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package DBIx::HTMLView::Log; |
|
22
|
|
|
|
|
|
|
require Exporter; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
7
|
use vars qw(@ISA @EXPORT); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
411
|
|
|
25
|
|
|
|
|
|
|
@ISA=qw(Exporter); |
|
26
|
|
|
|
|
|
|
@EXPORT=qw(make_log); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 make_log ($writecmd,$user,$filename); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
write into the file named $filename the log of the operation committed to |
|
31
|
|
|
|
|
|
|
the database. The sql statement is in $writecmd and the user name in $user. |
|
32
|
|
|
|
|
|
|
This function also add other things like date and time. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub make_log { |
|
38
|
0
|
|
|
0
|
1
|
|
my ($writecmd,$user,$filename)=@_; |
|
39
|
|
|
|
|
|
|
#$filename="/tmp/tstlog"; |
|
40
|
0
|
0
|
|
|
|
|
if (($filename cmp "")) { |
|
41
|
0
|
0
|
|
|
|
|
if ($writecmd !~ /^\s*select/i) { # skip if cmd is a select |
|
42
|
0
|
0
|
|
|
|
|
if (open (LOGF,">>".$filename)) { |
|
43
|
0
|
|
|
|
|
|
my ($sec,$min,$hour,$mday,$mon,$year)=localtime(); |
|
44
|
0
|
|
|
|
|
|
print LOGF ("\n"); |
|
45
|
0
|
|
|
|
|
|
print LOGF ($hour.':'); |
|
46
|
0
|
|
|
|
|
|
print LOGF ($min.':'); |
|
47
|
0
|
|
|
|
|
|
print LOGF ($sec.' '); |
|
48
|
0
|
|
|
|
|
|
print LOGF ($mday.'-'); |
|
49
|
0
|
|
|
|
|
|
print LOGF (($mon+1).'-'); |
|
50
|
0
|
|
|
|
|
|
print LOGF (($year+1900).' '); |
|
51
|
0
|
|
|
|
|
|
print LOGF ('USER='.$user.' '); |
|
52
|
0
|
|
|
|
|
|
print LOGF ('COMMAND='.$writecmd); |
|
53
|
0
|
|
|
|
|
|
close (LOGF); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |