Exemplo n.º 1
0
 // 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
     }
 }
Exemplo n.º 2
0
 static void withErrorsLogged(Action action)
 {
     try {
         action();
     } catch (Exception e) {
         LogC.err("exception caught from timer", e);
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 public void testLogStackTrace()
 {
     try {
         throw new Exception("outer", new NullReferenceException("inner"));
     } catch (Exception e) {
         LogC.err("logc err", e);
     }
 }
Exemplo n.º 5
0
        public bool clear()
        {
            var removedOne = false;

            lock (timers) {
                LogC.verbose(() => "T! (" + identity() + ")");
                each(item => removedOne = removedOne || remove(item));
            }
            return(removedOne);
        }
Exemplo n.º 6
0
 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;
     }
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 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);
     }
 }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
0
 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);
     }
 }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 [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;
     }
 }
Exemplo n.º 16
0
        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));
        }
Exemplo n.º 17
0
 public static void debug(string message)
 {
     LogC.debug(message);
 }
Exemplo n.º 18
0
 public static void info(string s)
 {
     LogC.info(s);
 }
Exemplo n.º 19
0
 public static void err(string s)
 {
     LogC.err(s);
 }
Exemplo n.º 20
0
 public override void tearDown()
 {
     base.tearDown();
     LogC.setOut("Test", null, false);
 }
Exemplo n.º 21
0
 public void initiate()
 {
     timerManager().everyMillis(waitMillis, publish, out timer);
     LogC.verbose(() => "initiated " + timer);
 }
Exemplo n.º 22
0
 public static void debug <T>(T t, string name)
 {
     LogC.debug(t, name + paren(t.GetType().FullName + "#" + t.GetHashCode()));
 }