From 845f1f47b63e9c811dfd15d384cd5c3fbc744cc1 Mon Sep 17 00:00:00 2001 From: samskivert Date: Wed, 10 Sep 2008 02:13:57 +0000 Subject: [PATCH] Some invoker jockeying requested by Charlie. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2410 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/Invoker.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/java/com/samskivert/util/Invoker.java b/src/java/com/samskivert/util/Invoker.java index 4c6da4a2..f14fb94d 100644 --- a/src/java/com/samskivert/util/Invoker.java +++ b/src/java/com/samskivert/util/Invoker.java @@ -103,6 +103,15 @@ public class Invoker extends LoopingThread return _defaultLongThreshold; } + /** + * Detail specific to this invoker to be included with the warning if this invoker takes + * longer than the long threshold. By default, no detail is included. + */ + public String getDetail () + { + return null; + } + /** Returns the name of this invoker. */ @Override public String toString () { @@ -238,9 +247,14 @@ public class Invoker extends LoopingThread // report long runners if (duration > unit.getLongThreshold()) { - String howLong = (duration >= 10*unit.getLongThreshold()) ? "Really long" : "Long"; - log.warning(howLong + " invoker unit [unit=" + unit + " (" + key + - "), time=" + duration + "ms]."); + StringBuilder msg = new StringBuilder(); + msg.append((duration >= 10*unit.getLongThreshold()) ? "Really long" : "Long"); + msg.append(" invoker unit [unit=").append(unit); + msg.append(" (").append(key).append("), time=").append(duration).append("ms"); + if (unit.getDetail() != null) { + msg.append(", detail=").append(unit.getDetail()); + } + log.warning(msg.append("].").toString()); } } }