@Test public void addIfNeeded_shouldNotAddIfInfoNotEnabled() throws Exception { context.checking(new Expectations() { { oneOf(logger).isInfoEnabled(); will(returnValue(false)); } }); assertFalse(LoggingFilter.addIfNeeded(logger, session, "wsn")); }
public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } LoggingFilter(Logger logger);  LoggingFilter(Logger logger, IoSession session, String transportName);  LoggingFilter(Logger logger, String sessionIdFormat); }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } LoggingFilter(Logger logger);  LoggingFilter(Logger logger, IoSession session, String transportName);  LoggingFilter(Logger logger, String sessionIdFormat); static boolean addIfNeeded(Logger logger, IoSession session, String transportName); LogLevel getLevel(); Logger getLogger(); String getFormat(); @Override void sessionCreated(NextFilter nextFilter,
                               IoSession session); @Override void sessionOpened(NextFilter nextFilter,
                              IoSession session); @Override void messageReceived(NextFilter nextFilter,
                                IoSession session,
                                Object message); @Override void messageSent(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); @Override void sessionIdle(NextFilter nextFilter,
                            IoSession session,
                            IdleStatus status); @Override void exceptionCaught(NextFilter nextFilter,
                                IoSession session,
                                Throwable cause); @Override void sessionClosed(NextFilter nextFilter,
                              IoSession session); @Override void filterWrite(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); static void moveAfterCodec(IoSession session); }
LoggingFilter extends IoFilterAdapter { public static boolean addIfNeeded(Logger logger, IoSession session, String transportName) { if (!logger.isInfoEnabled()) { return false; } String loggingFilterName = transportName + "#logging"; if (logger.isTraceEnabled()) { session.getFilterChain().addLast(loggingFilterName, new ObjectLoggingFilter(logger, session, transportName)); return true; } else { session.getFilterChain().addLast(loggingFilterName, new ExceptionLoggingFilter(logger, session, transportName)); return true; } } LoggingFilter(Logger logger);  LoggingFilter(Logger logger, IoSession session, String transportName);  LoggingFilter(Logger logger, String sessionIdFormat); static boolean addIfNeeded(Logger logger, IoSession session, String transportName); LogLevel getLevel(); Logger getLogger(); String getFormat(); @Override void sessionCreated(NextFilter nextFilter,
                               IoSession session); @Override void sessionOpened(NextFilter nextFilter,
                              IoSession session); @Override void messageReceived(NextFilter nextFilter,
                                IoSession session,
                                Object message); @Override void messageSent(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); @Override void sessionIdle(NextFilter nextFilter,
                            IoSession session,
                            IdleStatus status); @Override void exceptionCaught(NextFilter nextFilter,
                                IoSession session,
                                Throwable cause); @Override void sessionClosed(NextFilter nextFilter,
                              IoSession session); @Override void filterWrite(NextFilter nextFilter,
                            IoSession session,
                            WriteRequest writeRequest); static void moveAfterCodec(IoSession session);  }