Update of /cvsroot/sandweb/sandweb/lib/SandWeb
In directory usw-pr-cvs1:/tmp/cvs-serv17176/lib/SandWeb
Modified Files:
File.pm Log.pm
Log Message:
added debugging to the File class
Index: File.pm
===================================================================
RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/File.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -U2 -r1.21 -r1.22
--- File.pm 2001/12/20 02:58:02 1.21
+++ File.pm 2001/12/20 20:29:41 1.22
@@ -16,4 +16,5 @@
my $filename = $args{'filename'};
+ my $log_obj = $args{'log_obj'};
my $location = $args{'location'};
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
@@ -24,5 +25,5 @@
'filename' => $filename,
'location' => $location,
- 'log_obj' => $log,
+ 'log_obj' => $log_obj,
'mode' => $mode,
'uid' => $uid,
@@ -100,6 +101,13 @@
my $filename = $self->{'filename'};
my $contents = $args{'contents'};
+ my $log = $self->{'log_obj'};
- my $return = _do_file_write( 'contents' => "$contents" );
+ $log->debug("creating file : $location/$filename");
+ my $return = _do_file_write(
+ 'location' => $location,
+ 'filename' => $filename,
+ 'contents' => "$contents",
+ 'log_obj' => $log,
+ );
return $return;
@@ -112,6 +120,13 @@
my $log = $self->{'log_obj'};
- my $return = mkdir( "$location/$filename", "0336" );
+ $log->debug("creating folder : $location/$filename");
+ if (mkdir( "$location/$filename", "0336" )) {
+ $return = 1;
+ } else {
+ $log->debug("could not create folder $location/$filename : $!");
+ $return = 0;
+ }
+
return $return;
}
@@ -123,4 +138,6 @@
my $log = $self->{'log_obj'};
+ $log->debug("removing file : $location/$filename");
+
my $return = unlink("$location/$filename" );
@@ -134,4 +151,6 @@
my $log = $self->{'log_obj'};
+ $log->debug("removing folder : $location/$filename");
+
my $return = rmdir("$location/$filename" );
@@ -147,4 +166,6 @@
my $tofile = $args{'tofile'};
+ $log->debug("copying file : $location/$filename to $tofile");
+
my $file = SandWeb::File->new(
'location' => "$location",
@@ -153,5 +174,10 @@
my @fromfile = _do_file_read();
- _do_file_write( 'contents' => "@fromfile" );
+ _do_file_write(
+ 'filename' => $filename,
+ 'location' => $location,
+ 'contents' => "@fromfile",
+ 'log_obj' => $log,
+ );
return $return;
@@ -165,4 +191,6 @@
my $log = $self->{'log_obj'};
my $tofile = $args{'tofile'};
+
+ $log->debug("renaming file : $location/$filename to $tofile");
my $return = rename( "$location/$filename", "$tofile" );
@@ -180,4 +208,5 @@
'location' => "$location",
'filename' => "$filename",
+ 'log_obj' => $log,
);
@@ -199,4 +228,5 @@
'filename' => "$filename",
'contents' => "$contents",
+ 'log_obj' => $log,
);
@@ -221,8 +251,18 @@
my $filename = $args{'filename'};
my $contents = $args{'contents'};
+ my $log = $args{'log_obj'};
+ my $return;
- open (FILE, ">$location/$filename");
- print FILE $contents;
- my $return = close FILE;
+ if (open (FILE, ">$location/$filename")) {
+ print FILE $contents;
+ } else {
+ $log->debug("error opening $location/$filename for writing: $!");
+ }
+ if (close FILE) {
+ $return = 1;
+ } else {
+ $log->debug("error closing $location/$filename from writing: $!");
+ $return = 0;
+ }
return $return;
@@ -233,4 +273,5 @@
my $location = $args{'location'};
my $filename = $args{'filename'};
+ my $log = $args{'log_obj'};
open (FILE, "< $location/$filename");
Index: Log.pm
===================================================================
RCS file: /cvsroot/sandweb/sandweb/lib/SandWeb/Log.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- Log.pm 2001/10/06 07:51:56 1.5
+++ Log.pm 2001/12/20 20:29:41 1.6
@@ -1,6 +1,4 @@
-# SandWeb logging facility. this would use the standard perl
-# module for logging stuff
-# here is one standard module, do we need any in addition to this?
-# http://www.perl.com/pub/doc/manual/html/lib/Sys/Syslog.html
+# SandWeb logging facility
+#
package SandWeb::Log;
@@ -39,5 +37,5 @@
my ($caller) = caller();
- $self->_write_to_log("DEBUG: $caller $msg");
+ $self->_write_to_log("DEBUG: $caller $msg\n");
$self->_stack_debug("($caller) $msg");
}
|