net.tomp2p.connection
Class MessageLogger
java.lang.Object
net.tomp2p.connection.MessageLogger
- All Implemented Interfaces:
- org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler
@ChannelHandler.Sharable
public class MessageLogger
- extends Object
- implements org.jboss.netty.channel.ChannelUpstreamHandler
Prints the received message to a gzip encoded file. We omit to also store the send message because it will be the
same as the received:
peer A -> messsage request -> peer B
peer B -> message reply -> peer A
peer A (send request)
peer B (receive request) -> will be logged
peer B (send reply)
peer A (receive reply) -> will be logged
- Author:
- Thomas Bocek
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
org.jboss.netty.channel.ChannelHandler.Sharable |
Constructor Summary |
MessageLogger(File outputFile)
Creates a new message logger that outputs the received messages in a gzipped file. |
Method Summary |
void |
customMessage(String customMessage)
Prints out custom messages. |
void |
handleUpstream(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelEvent e)
|
void |
shutdown()
Shutdown the stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MessageLogger
public MessageLogger(File outputFile)
throws FileNotFoundException,
IOException
- Creates a new message logger that outputs the received messages in a gzipped file.
- Parameters:
outputFile
- The output file
- Throws:
FileNotFoundException
IOException
handleUpstream
public void handleUpstream(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelEvent e)
throws Exception
- Specified by:
handleUpstream
in interface org.jboss.netty.channel.ChannelUpstreamHandler
- Throws:
Exception
customMessage
public void customMessage(String customMessage)
- Prints out custom messages. This is useful for markers, e.g. from when to start logging or when a certain event
happend. The custom message will have "C:" at the beginning.
- Parameters:
customMessage
- The custom message
shutdown
public void shutdown()
- Shutdown the stream. Once is closed, it cannot be opened again.
Copyright © 2013. All Rights Reserved.