1 21 package oracle.toplink.essentials.logging; 23 24 import java.util.Date ; 25 import java.io.Serializable ; 26 import oracle.toplink.essentials.internal.sessions.AbstractSession; 27 import oracle.toplink.essentials.internal.databaseaccess.Accessor; 28 29 43 public class SessionLogEntry implements Serializable { 44 protected Date date; 45 protected transient AbstractSession session; 46 protected transient Thread thread; 47 protected transient Accessor connection; 48 protected String message; 49 protected Throwable throwable; 50 protected int level; 51 protected String nameSpace; 52 protected Object [] parameters; 53 protected boolean shouldTranslate; 54 55 59 public SessionLogEntry(AbstractSession session) { 60 this.date = new Date (); 61 this.thread = Thread.currentThread(); 62 this.session = session; 63 this.message = ""; 64 this.level = SessionLog.INFO; 65 } 66 67 71 public SessionLogEntry(AbstractSession session, Throwable throwable) { 72 this(session); 73 this.throwable = throwable; 74 this.level = SessionLog.SEVERE; 75 } 76 77 81 public SessionLogEntry(AbstractSession session, String message) { 82 this(session); 83 this.message = message; 84 } 85 86 90 public SessionLogEntry(AbstractSession session, String message, Accessor connection) { 91 this(session, message); 92 this.connection = connection; 93 } 94 95 99 public SessionLogEntry(int level, AbstractSession session, String message, Object [] params, Accessor connection, boolean shouldTranslate) { 100 this(session, message, connection); 101 this.level = level; 102 this.parameters = params; 103 this.shouldTranslate = shouldTranslate; 104 } 105 106 110 public SessionLogEntry(int level, String category, AbstractSession session, String message, Object [] params, Accessor connection, boolean shouldTranslate) { 111 this(level, session, message, params, connection, shouldTranslate); 112 this.nameSpace = category; 113 } 114 115 119 public SessionLogEntry(AbstractSession session, int level, String category, Throwable throwable) { 120 this(session, throwable); 121 this.level = level; 122 this.nameSpace = category; 123 } 124 125 129 public Accessor getConnection() { 130 return connection; 131 } 132 133 137 public Date getDate() { 138 return date; 139 } 140 141 145 public Throwable getException() { 146 return throwable; 147 } 148 149 153 public String getMessage() { 154 return message; 155 } 156 157 161 public AbstractSession getSession() { 162 return session; 163 } 164 165 169 public Thread getThread() { 170 return thread; 171 } 172 173 177 public int getLevel() { 178 return level; 179 } 180 181 185 public String getNameSpace() { 186 return nameSpace; 187 } 188 189 193 public Object [] getParameters() { 194 return parameters; 195 } 196 197 201 public boolean shouldTranslate() { 202 return shouldTranslate; 203 } 204 205 209 public boolean hasException() { 210 return getException() != null; 211 } 212 213 217 public void setConnection(Accessor connection) { 218 this.connection = connection; 219 } 220 221 225 public void setDate(Date date) { 226 this.date = date; 227 } 228 229 233 public void setException(Throwable throwable) { 234 this.throwable = throwable; 235 } 236 237 241 public void setMessage(String message) { 242 this.message = message; 243 } 244 245 249 public void setSession(AbstractSession session) { 250 this.session = session; 251 } 252 253 257 public void setThread(Thread thread) { 258 this.thread = thread; 259 } 260 261 265 public void setLevel(int level) { 266 this.level = level; 267 } 268 269 273 public void setNameSpace(String nameSpace) { 274 this.nameSpace = nameSpace; 275 } 276 277 281 public void setParameters(Object [] params) { 282 this.parameters = params; 283 } 284 285 289 public void setShouldTranslate(boolean shouldTranslate) { 290 this.shouldTranslate = shouldTranslate; 291 } 292 293 297 public String toString() { 298 return oracle.toplink.essentials.internal.helper.Helper.getShortClassName(getClass()) + "(" + getMessage() + ")"; 299 } 300 } 301 | Popular Tags |