Class NetLogClient

java.lang.Object
  extended byNetLogClient
All Implemented Interfaces:
DrinkLoggerSpec

public class NetLogClient
extends Object
implements DrinkLoggerSpec

The client side of the software that implements the remote logging capabilities for the drink software. The client simply connects to the server and sends the messages to the server. The server will log the date, the source machine, and the actual message.

Version:
$Revision: #9 $
Author:
Kevin Thompson [antiduh@csh.rit.edu]

Nested Class Summary
private  class NetLogClient.LogConnectionMgr
          This inner class is designed to maintain the socket connection from the NetLogClient to the NetLogServer.
 
Field Summary
private  Socket connection
          The connection to the server which actually stores the log.
private  String host
          The hostname or IP of the host we are connected to.
private  PrintWriter output
          The PrintWriter that is connected to the socket that we use for sending the log message to the server.
private  int port
          The port on the server that we are connected to.
 
Constructor Summary
NetLogClient(ConfigMgr configMgr)
          Set up the class using the configuration values from the given ConfigMgr.
 
Method Summary
 void initialize(String host, int port)
          Set up the client-side of the networked logging software.
private  void printDemarcation()
          A small helper method to print the demarcation that is printed when a new server session is started.
 void println(String message)
          Logs a message to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

private Socket connection
The connection to the server which actually stores the log. We simply send a line over the connection to the server to store a log message.


host

private String host
The hostname or IP of the host we are connected to.


port

private int port
The port on the server that we are connected to.


output

private PrintWriter output
The PrintWriter that is connected to the socket that we use for sending the log message to the server.

Constructor Detail

NetLogClient

public NetLogClient(ConfigMgr configMgr)
Set up the class using the configuration values from the given ConfigMgr.

Parameters:
configMgr - Where to get our runtime configuration values from.
Method Detail

initialize

public void initialize(String host,
                       int port)
Set up the client-side of the networked logging software.

Parameters:
host - The hostname or IP of the machine to use as the server.
port - The port on the host machine to connect to.

println

public void println(String message)
Logs a message to the server. If the message fails to send, then the method will return false.

Specified by:
println in interface DrinkLoggerSpec
Parameters:
message - The message to send to the server. The message should not not contain any time stamp or other such meta-data. The server will include this data. The message should contain just that - only the actual message.

printDemarcation

private void printDemarcation()
A small helper method to print the demarcation that is printed when a new server session is started.