logging cleanups

This commit is contained in:
zzz
2012-09-10 17:22:51 +00:00
parent 2f98d05e7c
commit 3781928693
4 changed files with 24 additions and 11 deletions

View File

@@ -389,7 +389,8 @@ class MessageOutputStream extends OutputStream {
// should we? To be researched further. // should we? To be researched further.
// false -> wait for completion, not just accept. // false -> wait for completion, not just accept.
flush(false); flush(false);
_log.debug("Output stream closed after writing " + _written); if (_log.shouldLog(Log.DEBUG))
_log.debug("Output stream closed after writing " + _written);
ByteArray ba = null; ByteArray ba = null;
synchronized (_dataLock) { synchronized (_dataLock) {
if (_buf != null) { if (_buf != null) {

View File

@@ -174,9 +174,13 @@ public class SimpleScheduler {
long time = System.currentTimeMillis() - before; long time = System.currentTimeMillis() - before;
if (time > 1000 && _log.shouldLog(Log.WARN)) if (time > 1000 && _log.shouldLog(Log.WARN))
_log.warn(_name + " wtf, event execution took " + time + ": " + _timedEvent); _log.warn(_name + " wtf, event execution took " + time + ": " + _timedEvent);
long completed = _executor.getCompletedTaskCount(); if (_log.shouldLog(Log.INFO)) {
if (_log.shouldLog(Log.INFO) && completed % 250 == 0) // this call is slow - iterates through a HashMap -
_log.info(debug()); // would be better to have a local AtomicLong if we care
long completed = _executor.getCompletedTaskCount();
if (completed % 250 == 0)
_log.info(debug());
}
} }
} }

View File

@@ -368,9 +368,13 @@ public class SimpleTimer2 {
long time = System.currentTimeMillis() - before; long time = System.currentTimeMillis() - before;
if (time > 500 && _log.shouldLog(Log.WARN)) if (time > 500 && _log.shouldLog(Log.WARN))
_log.warn(_pool + " wtf, event execution took " + time + ": " + this); _log.warn(_pool + " wtf, event execution took " + time + ": " + this);
long completed = _pool.getCompletedTaskCount(); if (_log.shouldLog(Log.INFO)) {
if (_log.shouldLog(Log.INFO) && completed % 250 == 0) // this call is slow - iterates through a HashMap -
_log.info(_pool.debug()); // would be better to have a local AtomicLong if we care
long completed = _pool.getCompletedTaskCount();
if (completed % 250 == 0)
_log.info(_pool.debug());
}
} }
/** /**
@@ -387,6 +391,7 @@ public class SimpleTimer2 {
return _name; return _name;
} }
/** warning - slow */
private long getCompletedTaskCount() { private long getCompletedTaskCount() {
return _executor.getCompletedTaskCount(); return _executor.getCompletedTaskCount();
} }

View File

@@ -449,7 +449,8 @@ class PersistentDataStore extends TransientDataStore {
// so add it here. // so add it here.
getContext().profileManager().heardAbout(ri.getIdentity().getHash(), ri.getPublished()); getContext().profileManager().heardAbout(ri.getIdentity().getHash(), ri.getPublished());
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
_log.info("Refused locally loaded routerInfo - deleting", iae); if (_log.shouldLog(Log.INFO))
_log.info("Refused locally loaded routerInfo - deleting", iae);
corrupt = true; corrupt = true;
} }
} }
@@ -524,10 +525,12 @@ class PersistentDataStore extends TransientDataStore {
File f = new File(dir, riName); File f = new File(dir, riName);
if (f.exists()) { if (f.exists()) {
boolean removed = f.delete(); boolean removed = f.delete();
if (!removed) if (!removed) {
_log.warn("Unable to remove router info at " + f.getAbsolutePath()); if (_log.shouldLog(Log.WARN))
else _log.warn("Unable to remove router info at " + f.getAbsolutePath());
} else if (_log.shouldLog(Log.INFO)) {
_log.info("Removed router info at " + f.getAbsolutePath()); _log.info("Removed router info at " + f.getAbsolutePath());
}
return; return;
} }
} }