PageBoxLib
Class HTTPLog

java.lang.Object
  extended byPageBoxLib.HTTPLog

public class HTTPLog
extends java.lang.Object

Data formatting and trace for raw HTTP troubleshooting. Traces only if httplog.txt exists in temporary directory

alexis.grandemange@pagebox.net

Copyright (c) 2002-2004 Alexis Grandemange

This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public License
 as published by the Free Software Foundation; version 2.1 of the
 License.
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU Lesser General Public License for more details.
 A copy of the GNU Lesser General Public License lesser.txt should be
 included in the distribution.

Version:
0, 0, 10
Author:
Alexis Grandemange

Field Summary
private  java.io.DataInputStream in
          Network input handle
private  java.io.DataOutputStream out
          Network output handle
private  java.io.PrintWriter pw
          Log file handle
private  java.text.SimpleDateFormat sdf
          SimpleDateFormat used to build log entries
private  java.lang.String to
          Target or source URL
 
Constructor Summary
HTTPLog(java.io.DataInputStream in, java.io.DataOutputStream out, java.lang.String to)
          Constructor.
 
Method Summary
 void close()
          Close both network output and log.
 void closeIn()
          Close network input.
 void closeOut()
          Close network output.
 void log(java.lang.String msg)
          Write an entry on the trace.
 boolean readBoolean()
          Read a boolean from the network input and log it.
 byte[] readBytes()
          Read a buffer from the network input and log it.
 int readInt()
          Read a int from the network input and log it.
 java.lang.String readString()
          Read a string from the network input and log it.
 void setIn(java.io.DataInputStream in)
          Set the network output stream.
 void setOut(java.io.DataOutputStream out)
          Set the network output stream.
 void write(boolean val)
          Write on both network and log.
 void write(byte[] buf)
          Write on both network and log.
 void write(int val)
          Write on both network and log.
 void write(java.lang.String msg)
          Write on both network and log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pw

private java.io.PrintWriter pw
Log file handle


in

private java.io.DataInputStream in
Network input handle


out

private java.io.DataOutputStream out
Network output handle


to

private java.lang.String to
Target or source URL


sdf

private final java.text.SimpleDateFormat sdf
SimpleDateFormat used to build log entries

Constructor Detail

HTTPLog

public HTTPLog(java.io.DataInputStream in,
               java.io.DataOutputStream out,
               java.lang.String to)
        throws java.io.IOException
Constructor. Opens the log file if requested.

Parameters:
in - network input stream
out - network output stream
to - target or source URL
Method Detail

setOut

public void setOut(java.io.DataOutputStream out)
Set the network output stream.

Parameters:
out - network output stream

setIn

public void setIn(java.io.DataInputStream in)
Set the network output stream.


write

public final void write(java.lang.String msg)
                 throws java.io.IOException
Write on both network and log.

Parameters:
msg - message to write
Throws:
java.io.IOException

write

public final void write(int val)
                 throws java.io.IOException
Write on both network and log.

Parameters:
val - int to write
Throws:
java.io.IOException

write

public final void write(boolean val)
                 throws java.io.IOException
Write on both network and log.

Parameters:
val - boolean to write
Throws:
java.io.IOException

write

public final void write(byte[] buf)
                 throws java.io.IOException
Write on both network and log.

Parameters:
buf - buffer to write
Throws:
java.io.IOException

readString

public final java.lang.String readString()
                                  throws java.io.IOException
Read a string from the network input and log it.

Returns:
string read from network
Throws:
java.io.IOException

readInt

public final int readInt()
                  throws java.io.IOException
Read a int from the network input and log it.

Returns:
int read from network
Throws:
java.io.IOException

readBoolean

public final boolean readBoolean()
                          throws java.io.IOException
Read a boolean from the network input and log it.

Returns:
boolean read from network
Throws:
java.io.IOException

readBytes

public final byte[] readBytes()
                       throws java.io.IOException
Read a buffer from the network input and log it.

Returns:
buffer read from network
Throws:
java.io.IOException

log

public final void log(java.lang.String msg)
Write an entry on the trace. Doesn't access to the network.

Parameters:
msg - message to write

closeIn

public final void closeIn()
                   throws java.io.IOException
Close network input.

Throws:
java.io.IOException

closeOut

public final void closeOut()
                    throws java.io.IOException
Close network output.

Throws:
java.io.IOException

close

public final void close()
                 throws java.io.IOException
Close both network output and log.

Throws:
java.io.IOException