// these methods are non-static, so that delegate comparisons to them work. protected void doNothing() { if (alwaysFalse()) { LogC.info("I'm doing nothing with " + this); // hide from static method suggestion } }
static void withErrorsLogged(Action action) { try { action(); } catch (Exception e) { LogC.err("exception caught from timer", e); } }
public void replace(T key, DateTime time, Action action) { lock (timers) { LogC.verbose(() => "TR (" + identity() + "): " + key + " for:" + ymdHuman(time)); remove(key); add(key, time, action); } }
public void testLogStackTrace() { try { throw new Exception("outer", new NullReferenceException("inner")); } catch (Exception e) { LogC.err("logc err", e); } }
public bool clear() { var removedOne = false; lock (timers) { LogC.verbose(() => "T! (" + identity() + ")"); each(item => removedOne = removedOne || remove(item)); } return(removedOne); }
public void add(T key, DateTime time, Action action) { lock (timers) { LogC.verbose(() => "T+ (" + identity() + "): " + key + " for:" + ymdHuman(time)); Bomb.existing(timers, key); Timer timer; timerManager().atTime(time, () => { lock (timers) timers.Remove(key); action(); }, out timer); timers[key] = timer; } }
public void testLogSetOutMultipleTimes() { LogC.setOut("Test", "foo", false); LogC.setOut("Test", "foo", false); LogC.setOut("Test", "bar", false); LogC.setOut("Test", "foo", false); LogC.setOut("Test", null, false); LogC.setOut("Test", null, false); LogC.setOut("Test", null, false); }
public static void Init() { try { Directory.CreateDirectory(@"C:\logs"); LogC.makeOld(TRACE_FILE_NAME); } catch { LogC.info("Cannot makeOld logfile (might be locked): " + TRACE_FILE_NAME, false); } JvmLoader.RegisterConfigurationHook(ConfigMethod); }
static void handleEachError <T>(IEnumerable <T> items, int i, T current, Exception e) { var currentStr = "tostring failed."; try { currentStr = current.ToString(); } catch (Exception tose) { LogC.err("tostring on item failed", tose); } throw Bomb.toss("failed@" + i + ", processing: " + currentStr + " in " + toShortString(items), e); }
void acquireTestLock() { while (O.trueDat()) { var otherLock = db.TestLocksTable.TEST_LOCK.tryAcquireLockOnce("test", GetType().FullName); if (otherLock.Equals(db.TestLocksTable.NONE)) { return; } LogC.info("waiting for test lock " + otherLock); O.sleep(350); } }
public static T condensedSql <T>(string s, Creator <T> result) { var debugState = Log.debugSql(); try { Log.doNotDebugSqlForever(); LogC.info(s); Log.info(s); return(result()); } finally { Log.setDebugSqlStateForever(debugState); } }
public void runTimers(DateTime time) { Bomb.unless(time.CompareTo(lastTestTimeRun) > 0, () => "attempting to run timers backwards or rerun the same time, \nlastTestTimeRun is " + ymdHuman(lastTestTimeRun) + "\nthis time: " + ymdHuman(time)); freezeNow(time); LogC.info("run " + Bomb.missing(allowedTimes, time) + " timers " + ymdHuman(time)); var actions = copy(timers.get(time)); timers.remove(time); allowedTimes.Remove(time); Bomb.when(isEmpty(actions), () => "no timers expecting to run on " + ymdHuman(time)); each(actions, action => action()); lastTestTimeRun = time; }
public bool remove(T key) { lock (timers) { Timer existing; if (timers.TryGetValue(key, out existing)) { LogC.verbose(() => "T- (" + identity() + "): " + key); existing.Dispose(); timers.Remove(key); return(true); } LogC.verbose(() => "T* (" + identity() + "): " + key); return(false); } }
public static string report(string description) { if (get(description).iterations == 0) { return(""); } var result = description + " - total millis: " + toShortString(millis(description)) + ", " + get(description).iterations + "x" + toShortString(millisPer(description)); if (memory) { result += " bytesUsed: " + toShortString(bytesUsed(description)) + ", x" + toShortString(bytesUsedPer(description)); } LogC.info(result); return(result); }
[SetUp] public void setUpWithTeardown() { try { LogC.consoleOut("setUpWithTeardown"); LogC.setOut("setup " + this, null, false); LogC.setVerboseLoggingForever(true); LogC.info("Starting " + this); Log.info("Starting " + this); setUp(); } catch { try { tearDown(); } catch (Exception e) { LogC.err("failed in teardown after failing in setup! ", e); } throw; } }
public static bool isEnvSet(string key, bool defalt) { var human = Environment.GetEnvironmentVariable(key); if (isEmpty(human)) { if (!envNotified.ContainsKey(key)) { LogC.info("ENV: " + key + "=" + defalt + "(default)"); envNotified.Add(key, 1); } return(defalt); } if (!envNotified.ContainsKey(key)) { LogC.info("ENV: " + key + "=" + human); envNotified.Add(key, 1); } return(Strings.toBoolean(human, defalt)); }
public static void debug(string message) { LogC.debug(message); }
public static void info(string s) { LogC.info(s); }
public static void err(string s) { LogC.err(s); }
public override void tearDown() { base.tearDown(); LogC.setOut("Test", null, false); }
public void initiate() { timerManager().everyMillis(waitMillis, publish, out timer); LogC.verbose(() => "initiated " + timer); }
public static void debug <T>(T t, string name) { LogC.debug(t, name + paren(t.GetType().FullName + "#" + t.GetHashCode())); }