Improve thread naming and include thread ids in helma log message.
This commit is contained in:
parent
3af404d39e
commit
ee391ae6db
3 changed files with 14 additions and 6 deletions
|
@ -342,7 +342,7 @@ public final class Application implements Runnable {
|
||||||
String ignoreDirs;
|
String ignoreDirs;
|
||||||
|
|
||||||
Initializer(String dirs) {
|
Initializer(String dirs) {
|
||||||
super("INIT-" + name);
|
super(name + "-init");
|
||||||
ignoreDirs = dirs;
|
ignoreDirs = dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ public final class Application implements Runnable {
|
||||||
releaseEvaluator(eval);
|
releaseEvaluator(eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
worker = new Thread(this, "Worker-" + name);
|
worker = new Thread(this, name + "-worker");
|
||||||
worker.setPriority(Thread.NORM_PRIORITY + 1);
|
worker.setPriority(Thread.NORM_PRIORITY + 1);
|
||||||
worker.start();
|
worker.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,10 @@ public final class RequestEvaluator implements Runnable {
|
||||||
// the exception thrown by the evaluator, if any.
|
// the exception thrown by the evaluator, if any.
|
||||||
private volatile Exception exception;
|
private volatile Exception exception;
|
||||||
|
|
||||||
|
// For numbering threads.
|
||||||
|
private int threadId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new RequestEvaluator for this application.
|
* Create a new RequestEvaluator for this application.
|
||||||
* @param app the application
|
* @param app the application
|
||||||
|
@ -668,7 +672,7 @@ public final class RequestEvaluator implements Runnable {
|
||||||
|
|
||||||
if ((thread == null) || !thread.isAlive()) {
|
if ((thread == null) || !thread.isAlive()) {
|
||||||
// app.logEvent ("Starting Thread");
|
// app.logEvent ("Starting Thread");
|
||||||
thread = new Thread(app.threadgroup, this);
|
thread = new Thread(app.threadgroup, this, app.getName() + "-" + (++threadId));
|
||||||
thread.setContextClassLoader(app.getClassLoader());
|
thread.setContextClassLoader(app.getClassLoader());
|
||||||
thread.start();
|
thread.start();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -143,7 +143,9 @@ public class Logger implements Log {
|
||||||
// has gone. the 2000 entries threshold is somewhat arbitrary.
|
// has gone. the 2000 entries threshold is somewhat arbitrary.
|
||||||
if (entries.size() < 2000) {
|
if (entries.size() < 2000) {
|
||||||
String message = msg == null ? "null" : msg.toString();
|
String message = msg == null ? "null" : msg.toString();
|
||||||
entries.add(new Entry(dateCache, level, message, exception));
|
Thread thread = Thread.currentThread();
|
||||||
|
String threadId = "[" + thread.getName() + "] ";
|
||||||
|
entries.add(new Entry(dateCache, level, message, threadId, exception));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +166,7 @@ public class Logger implements Log {
|
||||||
Entry entry = (Entry) entries.remove(0);
|
Entry entry = (Entry) entries.remove(0);
|
||||||
writer.print(entry.date);
|
writer.print(entry.date);
|
||||||
writer.print(entry.level);
|
writer.print(entry.level);
|
||||||
|
writer.print(entry.threadId);
|
||||||
writer.println(entry.message);
|
writer.println(entry.message);
|
||||||
if (entry.exception != null)
|
if (entry.exception != null)
|
||||||
entry.exception.printStackTrace(writer);
|
entry.exception.printStackTrace(writer);
|
||||||
|
@ -294,13 +297,14 @@ public class Logger implements Log {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Entry {
|
class Entry {
|
||||||
final String date, level, message;
|
final String date, level, message, threadId;
|
||||||
final Throwable exception;
|
final Throwable exception;
|
||||||
|
|
||||||
Entry(String date, String level, String message, Throwable exception) {
|
Entry(String date, String level, String message, String threadId, Throwable exception) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
this.threadId = threadId;
|
||||||
this.exception = exception;
|
this.exception = exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue