1 package org.jzonic.jlo; 2 3 import java.io.PrintWriter ; 4 import java.io.StringWriter ; 5 11 public class LogRecord { 12 13 private String msg; 14 private long logdate; 15 private String loggername; 16 private String sourceClass = null; 17 private String sourceMethod = null; 18 private Throwable thrown; 19 private Target target; 20 private String configurationName; 21 private long elapsed; 22 private String ndc; 23 28 public LogRecord(String msg) { 29 this(msg, null); 30 } 31 32 33 39 public LogRecord(String msg, Target target) { 40 this.msg = msg; 41 this.target = target; 42 logdate = System.currentTimeMillis(); 43 44 } 45 46 47 52 public Target getTarget() { 53 return target; 54 } 55 56 57 62 public String getLoggerName() { 63 return loggername; 64 } 65 66 67 72 public String getMessage() { 73 return msg; 74 } 75 76 77 82 public long getMillis() { 83 return logdate; 84 } 85 86 87 92 public String getSourceClassName() { 93 return sourceClass; 94 } 95 96 97 102 public String getSourceMethodName() { 103 return sourceMethod; 104 } 105 106 107 112 public Throwable getThrown() { 113 return thrown; 114 } 115 116 117 122 public void setTarget(Target target) { 123 this.target = target; 124 } 125 126 127 132 public void setLoggerName(String name) { 133 loggername = name; 134 } 135 136 137 142 public void setMessage(String message) { 143 msg = message; 144 } 145 146 147 152 public void setMillis(long millis) { 153 logdate = millis; 154 } 155 156 157 162 public void setSourceClassName(String sourceClassName) { 163 sourceClass = sourceClassName; 164 } 165 166 167 172 public void setSourceMethodName(String sourceMethodName) { 173 sourceMethod = sourceMethodName; 174 } 175 176 177 182 public void setThrown(Throwable thrown) { 183 this.thrown = thrown; 184 } 185 186 public String getStackTrace() { 187 if ( thrown != null ) { 188 StringWriter sw = new StringWriter (); 189 PrintWriter pw = new PrintWriter ( sw ); 190 thrown.printStackTrace( pw ); 191 pw.close(); 192 return sw.getBuffer().toString(); 193 } 194 else { 195 return ""; 196 } 197 } 198 199 203 public String getConfigurationName() { 204 return configurationName; 205 } 206 207 211 public void setConfigurationName(String configurationName) { 212 this.configurationName = configurationName; 213 } 214 215 public String getNDC() { 216 return ndc; 217 } 218 219 public void setNDC(String ndc) { 220 this.ndc = ndc; 221 } 222 223 public void setElapsed(long elapsed) { 224 this.elapsed = elapsed; 225 } 226 227 public long getElapsed() { 228 return elapsed; 229 } 230 231 } 232 | Popular Tags |