| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
package com.netscape.javascript.qa.drivers; |
| 7 |
|
| 8 |
|
| 9 |
import java.io.*; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
public class TestLog { |
| 18 |
private String name; |
| 19 |
private ByteArrayOutputStream outputStream; |
| 20 |
private PrintStream printStream; |
| 21 |
private String terminator; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public TestLog ( String name, String terminator ) { |
| 32 |
this.name = name; |
| 33 |
this.terminator = terminator; |
| 34 |
|
| 35 |
openLog(); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public void writeLine( String string ) { |
| 42 |
if ( printStream != null ) { |
| 43 |
printStream.println( string + terminator ); |
| 44 |
try { |
| 45 |
RandomAccessFile raf = new RandomAccessFile( name, "rw" ); |
| 46 |
raf.seek( raf.length() ); |
| 47 |
raf.write( outputStream.toByteArray() ); |
| 48 |
raf.close(); |
| 49 |
outputStream.reset(); |
| 50 |
} catch ( Exception e ) { |
| 51 |
System.out.println( "Exception writing to "+ name +".writeLine():"+ e ); |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public void enablePrivileges() { |
| 61 |
return; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public void closeLog() { |
| 68 |
if ( printStream != null ) { |
| 69 |
printStream.close(); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public void openLog() { |
| 76 |
enablePrivileges(); |
| 77 |
this.outputStream = new ByteArrayOutputStream(); |
| 78 |
this.printStream = new PrintStream( this.outputStream ); |
| 79 |
} |
| 80 |
|
| 81 |
public String toString() { |
| 82 |
return this.name; |
| 83 |
} |
| 84 |
} |