tuwien.auto.calimero.log
Class LogNetWriter

java.lang.Object
  extended by tuwien.auto.calimero.log.LogWriter
      extended by tuwien.auto.calimero.log.LogStreamWriter
          extended by tuwien.auto.calimero.log.LogNetWriter

public class LogNetWriter
extends LogStreamWriter

A LogNetWriter is used to log information over a socket network connection.

A destination host is supplied on creation of this log writer, a Socket TCP connection is opened and used for further logging. After close()ing the log writer, it cannot be connected again.
For output on the socket the platform's default character set is used.

See Also:
Socket

Field Summary
protected  java.net.Socket s
          Socket connection used as logging destination.
 
Fields inherited from class tuwien.auto.calimero.log.LogStreamWriter
c, formatOutput, lineSep
 
Constructor Summary
LogNetWriter(LogLevel level, java.lang.String host, int port)
          Like LogNetWriter(String, int) with the ability to set the filter log level for information logged by LogNetWriter.
LogNetWriter(java.lang.String host, int port)
          Creates a log writer and opens a socket connection to destination host and port.
 
Method Summary
 void close()
          Closes the LogWriter and all its resources.
 java.lang.String getHostAddress()
          Returns the remote host IP address of this log writer, or "" if the connection was closed.
 java.lang.String getHostName()
          Returns the remote host name of this log writer, or "" if the connection was closed.
 int getPort()
          Returns the destination port of this log writer, or 0 if the connection was closed.
 
Methods inherited from class tuwien.auto.calimero.log.LogStreamWriter
flush, formatOutput, logAllowed, setOutput, write, write
 
Methods inherited from class tuwien.auto.calimero.log.LogWriter
getErrorHandler, getLogLevel, setErrorHandler, setLogLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s

protected java.net.Socket s
Socket connection used as logging destination.

Constructor Detail

LogNetWriter

public LogNetWriter(LogLevel level,
                    java.lang.String host,
                    int port)
             throws KNXLogException
Like LogNetWriter(String, int) with the ability to set the filter log level for information logged by LogNetWriter.

Parameters:
level - log level used by this LogWriter to filter log information
host - destination host name or IP address in textual presentation; if null or an empty string is specified, an address of the loopback interface is used
port - destination port, 0 <= port <= 65535
Throws:
KNXLogException - if IP address of host could not be determined or socket binding / connecting failed

LogNetWriter

public LogNetWriter(java.lang.String host,
                    int port)
             throws KNXLogException
Creates a log writer and opens a socket connection to destination host and port.

Parameters:
host - destination host name or IP address in textual presentation; if null or an empty string is specified, an address of the loopback interface is used
port - destination port, 0 <= port <= 65535
Throws:
KNXLogException - if IP address of host could not be determined or socket binding / connecting failed
See Also:
Socket
Method Detail

close

public void close()
Description copied from class: LogWriter
Closes the LogWriter and all its resources.

If necessary, all output is flushes before.

Overrides:
close in class LogStreamWriter

getHostAddress

public final java.lang.String getHostAddress()
Returns the remote host IP address of this log writer, or "" if the connection was closed.

Returns:
IP address as String
See Also:
InetAddress.getHostAddress()

getHostName

public final java.lang.String getHostName()
Returns the remote host name of this log writer, or "" if the connection was closed.

Note that this might involve a reverse name lookup. It is possible that only the IP address string is returned.

Returns:
host name (or IP address) as String
See Also:
InetAddress.getHostName()

getPort

public final int getPort()
Returns the destination port of this log writer, or 0 if the connection was closed.

Returns:
port number as unsigned