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 TypeMethodDescriptionvoid
channelRead
(ChannelHandlerContext ctx, Object msg) void
static void
log
(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, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
RequestLogger
public RequestLogger()
-
-
Method Details
-
channelRead
- Specified by:
channelRead
in interfaceChannelInboundHandler
- Overrides:
channelRead
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
channelReadComplete
- Specified by:
channelReadComplete
in interfaceChannelInboundHandler
- Overrides:
channelReadComplete
in 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 anyProxy
orX-Proxy
headers for privacy- Parameters:
ctx
- the context to log
-