From: adash Date: Sat, 28 Oct 2006 00:58:05 +0000 (+0000) Subject: Log the webserver requests X-Git-Tag: preEdgeChange~802 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=420c3e2408e9081e5a0e760993e26e63f2d3a072;p=IRC.git Log the webserver requests Add append functionality in a file for logging all requests --- diff --git a/Robust/src/ClassLibrary/FileOutputStream.java b/Robust/src/ClassLibrary/FileOutputStream.java index 04c589c3..ed81ed7c 100644 --- a/Robust/src/ClassLibrary/FileOutputStream.java +++ b/Robust/src/ClassLibrary/FileOutputStream.java @@ -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); diff --git a/Robust/src/Runtime/file.c b/Robust/src/Runtime/file.c index bee9b96f..fa8343dc 100644 --- a/Robust/src/Runtime/file.c +++ b/Robust/src/Runtime/file.c @@ -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 index 00000000..0603758e --- /dev/null +++ b/Robust/src/Tests/Logger.java @@ -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(); + } + +}