Package com.gmt2001.httpwsserver
Class RequestLogger
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
com.gmt2001.httpwsserver.RequestLogger
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler
Provides a method to log a request stream
- Author:
- gmt2001
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead(ChannelHandlerContext ctx, Object msg) voidstatic voidlog(ChannelHandlerContext ctx) Logs the request stream of the provided context and prints the file path to the consoleMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
RequestLogger
public RequestLogger()
-
-
Method Details
-
channelRead
- Specified by:
channelReadin interfaceChannelInboundHandler- Overrides:
channelReadin classChannelInboundHandlerAdapter- Throws:
Exception
-
channelReadComplete
- Specified by:
channelReadCompletein interfaceChannelInboundHandler- Overrides:
channelReadCompletein classChannelInboundHandlerAdapter- Throws:
Exception
-
log
Logs the request stream of the provided context and prints the file path to the consoleRequests are logged to the ./logs/request/ folder in a file with the timestamp of the request
This method attempts to redact the
Host,Cookie,Authorization,Referrer, and anyProxyorX-Proxyheaders for privacy- Parameters:
ctx- the context to log
-