net.gleamynode.netty2
Class SessionLog
java.lang.Object
net.gleamynode.netty2.SessionLog
- All Implemented Interfaces:
- org.apache.commons.logging.Log
public class SessionLog
- extends Object
- implements org.apache.commons.logging.Log
Apache Jakarta Commons Logging helper.
Log message format is '[socketAddress] User message
'.
You can use this class in two ways:
- Static:
private static final Log log = LogFactory.getLog(MySessionListener.class);
...
public void messageReceived(Session s, Message m) {
SessionLog.info(log, s, "Received: " + m);
...
}
- Non-static (Please note that this code assumes
connectionEstablished
event is
always fired in prior to other events):
private static final Log log = LogFactory.getLog(MySessionListener.class);
public class MySessionInfo {
private final SessionLog log;
...
public MySessionInfo(Session session) {
log = new SessionLog(session, LogFactory.getLog(MySessionListener.class);
...
}
public Log getLog() {
return log;
}
...
}
public class MySessionListener implements SessionListener {
public void connectionEstablished(Session s) {
MySessionInfo info = new MySessionInfo(s);
s.setAttachment(new MySessionInfo(s));
info.getLog().info("Connection established.");
...
}
public void messageReceived(Session s, Message m) {
MySessionInfo info = (MySessionInfo) s.getAttachment();
info.getLog().info("Received: " + m);
...
}
...
}
- Version:
- $Rev: 4 $, $Date: 2005-04-18 12:04:09 +0900 $
- Author:
- Trustin Lee (http://gleamynode.net/)
Method Summary |
static void |
debug(org.apache.commons.logging.Log log,
Session session,
Object obj)
|
static void |
debug(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
|
void |
debug(Object obj)
|
void |
debug(Object obj,
Throwable cause)
|
static void |
error(org.apache.commons.logging.Log log,
Session session,
Object obj)
|
static void |
error(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
|
void |
error(Object obj)
|
void |
error(Object obj,
Throwable cause)
|
static void |
fatal(org.apache.commons.logging.Log log,
Session session,
Object obj)
|
static void |
fatal(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
|
void |
fatal(Object obj)
|
void |
fatal(Object obj,
Throwable cause)
|
static void |
info(org.apache.commons.logging.Log log,
Session session,
Object obj)
|
static void |
info(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
|
void |
info(Object obj)
|
void |
info(Object obj,
Throwable cause)
|
boolean |
isDebugEnabled()
|
boolean |
isErrorEnabled()
|
boolean |
isFatalEnabled()
|
boolean |
isInfoEnabled()
|
boolean |
isTraceEnabled()
|
boolean |
isWarnEnabled()
|
static void |
trace(org.apache.commons.logging.Log log,
Session session,
Object obj)
|
static void |
trace(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
|
void |
trace(Object obj)
|
void |
trace(Object obj,
Throwable cause)
|
static void |
warn(org.apache.commons.logging.Log log,
Session session,
Object obj)
|
static void |
warn(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
|
void |
warn(Object obj)
|
void |
warn(Object obj,
Throwable cause)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SessionLog
public SessionLog(Session session,
org.apache.commons.logging.Log log)
trace
public static void trace(org.apache.commons.logging.Log log,
Session session,
Object obj)
trace
public static void trace(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
debug
public static void debug(org.apache.commons.logging.Log log,
Session session,
Object obj)
debug
public static void debug(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
info
public static void info(org.apache.commons.logging.Log log,
Session session,
Object obj)
info
public static void info(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
warn
public static void warn(org.apache.commons.logging.Log log,
Session session,
Object obj)
warn
public static void warn(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
error
public static void error(org.apache.commons.logging.Log log,
Session session,
Object obj)
error
public static void error(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
fatal
public static void fatal(org.apache.commons.logging.Log log,
Session session,
Object obj)
fatal
public static void fatal(org.apache.commons.logging.Log log,
Session session,
Object obj,
Throwable cause)
isDebugEnabled
public boolean isDebugEnabled()
- Specified by:
isDebugEnabled
in interface org.apache.commons.logging.Log
isErrorEnabled
public boolean isErrorEnabled()
- Specified by:
isErrorEnabled
in interface org.apache.commons.logging.Log
isFatalEnabled
public boolean isFatalEnabled()
- Specified by:
isFatalEnabled
in interface org.apache.commons.logging.Log
isInfoEnabled
public boolean isInfoEnabled()
- Specified by:
isInfoEnabled
in interface org.apache.commons.logging.Log
isTraceEnabled
public boolean isTraceEnabled()
- Specified by:
isTraceEnabled
in interface org.apache.commons.logging.Log
isWarnEnabled
public boolean isWarnEnabled()
- Specified by:
isWarnEnabled
in interface org.apache.commons.logging.Log
trace
public void trace(Object obj)
- Specified by:
trace
in interface org.apache.commons.logging.Log
trace
public void trace(Object obj,
Throwable cause)
- Specified by:
trace
in interface org.apache.commons.logging.Log
debug
public void debug(Object obj)
- Specified by:
debug
in interface org.apache.commons.logging.Log
debug
public void debug(Object obj,
Throwable cause)
- Specified by:
debug
in interface org.apache.commons.logging.Log
info
public void info(Object obj)
- Specified by:
info
in interface org.apache.commons.logging.Log
info
public void info(Object obj,
Throwable cause)
- Specified by:
info
in interface org.apache.commons.logging.Log
warn
public void warn(Object obj)
- Specified by:
warn
in interface org.apache.commons.logging.Log
warn
public void warn(Object obj,
Throwable cause)
- Specified by:
warn
in interface org.apache.commons.logging.Log
error
public void error(Object obj)
- Specified by:
error
in interface org.apache.commons.logging.Log
error
public void error(Object obj,
Throwable cause)
- Specified by:
error
in interface org.apache.commons.logging.Log
fatal
public void fatal(Object obj)
- Specified by:
fatal
in interface org.apache.commons.logging.Log
fatal
public void fatal(Object obj,
Throwable cause)
- Specified by:
fatal
in interface org.apache.commons.logging.Log
Copyright © 2004-2008 Trustin Lee. All Rights Reserved.