Log the webserver requests
authoradash <adash>
Sat, 28 Oct 2006 00:58:05 +0000 (00:58 +0000)
committeradash <adash>
Sat, 28 Oct 2006 00:58:05 +0000 (00:58 +0000)
Add append functionality in a file for logging all requests

Robust/src/ClassLibrary/FileOutputStream.java
Robust/src/Runtime/file.c
Robust/src/Tests/Logger.java [new file with mode: 0644]

index 04c589c3b74dd907e8b245c2b7c63369c9917ae0..ed81ed7cd35ae2be458ddf95f1900cd1bf55d642 100644 (file)
@@ -5,11 +5,20 @@ public class FileOutputStream {
        fd=nativeOpen(pathname.getBytes());
     }
 
+    public FileOutputStream(String pathname, int mode) {
+       if(mode==0)     
+               fd=nativeAppend(pathname.getBytes());
+       if(mode==1)
+               fd=nativeOpen(pathname.getBytes());
+    }
+
+
     public FileOutputStream(File path) {
        fd=nativeOpen(path.getPath().getBytes());
     }
 
     private static native int nativeOpen(byte[] filename);
+    private static native int nativeAppend(byte[] filename);
     private static native void nativeWrite(int fd, byte[] array);
     private static native void nativeClose(int fd);
     
index bee9b96fe280eb8b89772e4a9d141bbb9e0ba257..fa8343dcbdf05d519c99127ccd1533ed960ff3c3 100644 (file)
@@ -24,6 +24,13 @@ int ___FileOutputStream______nativeOpen_____AR_B(struct ArrayObject * ao) {
   return fd;
 }
 
+int ___FileOutputStream______nativeAppend_____AR_B(struct ArrayObject * ao) {
+  int length=ao->___length___;
+  char* filename= (((char *)& ao->___length___)+sizeof(int));
+  int fd=open(filename, O_WRONLY|O_CREAT|O_APPEND, S_IRWXU);
+  return fd;
+}
+
 int ___FileInputStream______nativeOpen_____AR_B(struct ArrayObject * ao) {
   int length=ao->___length___;
   char* filename= (((char *)& ao->___length___)+sizeof(int));
diff --git a/Robust/src/Tests/Logger.java b/Robust/src/Tests/Logger.java
new file mode 100644 (file)
index 0000000..0603758
--- /dev/null
@@ -0,0 +1,18 @@
+public class Logger extends FileOutputStream {
+       //Logging flag
+       flag LogPending;
+       
+       //Constructor
+       public Logger(){
+       }
+
+       public void logrequest(){
+               String filepath = new String("./Tests/htmlfiles/request.log");
+               String request = new String(" New Request received\n");
+               int mode=0;
+               FileOutputStream logfile = new FileOutputStream(filepath,mode);
+               logfile.write(request.getBytes());
+               logfile.close();        
+       }
+
+}