From 0d864ff8783d890720c6d269025fefa2985895ec Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 27 Jul 2003 17:29:26 +0000 Subject: [PATCH] Use setLogIntervals to log every time an interval is fired. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1176 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/util/IntervalManager.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java b/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java index 4d7b286a..374e73a9 100644 --- a/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java +++ b/projects/samskivert/src/java/com/samskivert/util/IntervalManager.java @@ -1,5 +1,5 @@ // -// $Id: IntervalManager.java,v 1.8 2002/08/09 23:33:38 shaper Exp $ +// $Id: IntervalManager.java,v 1.9 2003/07/27 17:29:26 ray Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -95,6 +95,14 @@ public class IntervalManager } } + /** + * Turn on or off logging of all interval firings. + */ + public static void setLogIntervals (boolean log) + { + _logging = log; + } + /** The timer we use to schedule everything. */ protected static Timer _timer = new Timer(true); @@ -102,6 +110,9 @@ public class IntervalManager protected static IntMap _hash = Collections.synchronizedIntMap(new HashIntMap()); + /** Whether or not we're logging interval fires. */ + protected static boolean _logging = false; + /** * A class to adapt {@link TimerTask} to the smooth action of {@link * Interval}. @@ -112,6 +123,7 @@ public class IntervalManager protected Interval _i; protected Object _arg; protected boolean _onetime; + protected String _source; public IntervalTask (Interval i, Object arg, boolean recur) { @@ -119,6 +131,11 @@ public class IntervalManager _arg = arg; _onetime = !recur; id = nextID(); + try { + _source = new Throwable().getStackTrace()[2].toString(); + } catch (Throwable oopsie) { + _source = ""; + } } /** @@ -128,6 +145,10 @@ public class IntervalManager */ public void run () { + if (_logging) { + System.err.println("Interval fired [source=" + _source + "]"); + } + // protect our ass. try { _i.intervalExpired(id, _arg);