Lines 177-183
Link Here
|
177 |
this.rotatable = rotatable; |
177 |
this.rotatable = rotatable; |
178 |
this.bufferSize = bufferSize; |
178 |
this.bufferSize = bufferSize; |
179 |
configure(); |
179 |
configure(); |
180 |
openWriter(); |
|
|
181 |
clean(); |
180 |
clean(); |
182 |
} |
181 |
} |
183 |
|
182 |
|
Lines 186-195
Link Here
|
186 |
|
185 |
|
187 |
|
186 |
|
188 |
/** |
187 |
/** |
189 |
* The as-of date for the currently open log file, or a zero-length |
188 |
* The as-of date for the currently open log file, or null if there is no |
190 |
* string if there is no open log file. |
189 |
* open log file. |
191 |
*/ |
190 |
*/ |
192 |
private volatile String date = ""; |
191 |
private volatile String date = null; |
193 |
|
192 |
|
194 |
|
193 |
|
195 |
/** |
194 |
/** |
Lines 262-281
Link Here
|
262 |
return; |
261 |
return; |
263 |
} |
262 |
} |
264 |
|
263 |
|
265 |
// Construct the timestamp we will use, if requested |
264 |
final String tsDate; |
266 |
Timestamp ts = new Timestamp(System.currentTimeMillis()); |
265 |
if (rotatable.booleanValue()) { |
267 |
String tsDate = ts.toString().substring(0, 10); |
266 |
// Construct the timestamp we will use |
|
|
267 |
Timestamp ts = new Timestamp(System.currentTimeMillis()); |
268 |
tsDate = ts.toString().substring(0, 10); |
269 |
} else { |
270 |
tsDate = ""; |
271 |
} |
268 |
|
272 |
|
269 |
writerLock.readLock().lock(); |
273 |
writerLock.readLock().lock(); |
270 |
try { |
274 |
try { |
271 |
// If the date has changed, switch log files |
275 |
// If the date has changed, switch log files |
272 |
if (rotatable.booleanValue() && !date.equals(tsDate)) { |
276 |
if (!tsDate.equals(date)) { |
273 |
// Upgrade to writeLock before we switch |
277 |
// Upgrade to writeLock before we switch |
274 |
writerLock.readLock().unlock(); |
278 |
writerLock.readLock().unlock(); |
275 |
writerLock.writeLock().lock(); |
279 |
writerLock.writeLock().lock(); |
276 |
try { |
280 |
try { |
277 |
// Make sure another thread hasn't already done this |
281 |
// Make sure another thread hasn't already done this |
278 |
if (!date.equals(tsDate)) { |
282 |
if (!tsDate.equals(date)) { |
279 |
closeWriter(); |
283 |
closeWriter(); |
280 |
date = tsDate; |
284 |
date = tsDate; |
281 |
openWriter(); |
285 |
openWriter(); |
Lines 338-344
Link Here
|
338 |
writer.flush(); |
342 |
writer.flush(); |
339 |
writer.close(); |
343 |
writer.close(); |
340 |
writer = null; |
344 |
writer = null; |
341 |
date = ""; |
345 |
date = null; |
342 |
} catch (Exception e) { |
346 |
} catch (Exception e) { |
343 |
reportError(null, e, ErrorManager.CLOSE_FAILURE); |
347 |
reportError(null, e, ErrorManager.CLOSE_FAILURE); |
344 |
} finally { |
348 |
} finally { |
Lines 373-381
Link Here
|
373 |
*/ |
377 |
*/ |
374 |
private void configure() { |
378 |
private void configure() { |
375 |
|
379 |
|
376 |
Timestamp ts = new Timestamp(System.currentTimeMillis()); |
|
|
377 |
date = ts.toString().substring(0, 10); |
378 |
|
379 |
String className = this.getClass().getName(); //allow classes to override |
380 |
String className = this.getClass().getName(); //allow classes to override |
380 |
|
381 |
|
381 |
ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
382 |
ClassLoader cl = Thread.currentThread().getContextClassLoader(); |