예제 #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
     }
 }
예제 #2
0
 static void withErrorsLogged(Action action)
 {
     try {
         action();
     } catch (Exception e) {
         LogC.err("exception caught from timer", e);
     }
 }
예제 #3
0
파일: Timers.cs 프로젝트: TzarIvan/ratel
 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);
     }
 }
예제 #4
0
파일: TestLogC.cs 프로젝트: TzarIvan/ratel
 public void testLogStackTrace()
 {
     try {
         throw new Exception("outer", new NullReferenceException("inner"));
     } catch (Exception e) {
         LogC.err("logc err", e);
     }
 }
예제 #5
0
파일: Timers.cs 프로젝트: TzarIvan/ratel
        public bool clear()
        {
            var removedOne = false;

            lock (timers) {
                LogC.verbose(() => "T! (" + identity() + ")");
                each(item => removedOne = removedOne || remove(item));
            }
            return(removedOne);
        }
예제 #6
0
파일: Timers.cs 프로젝트: TzarIvan/ratel
 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;
     }
 }
예제 #7
0
파일: TestLogC.cs 프로젝트: TzarIvan/ratel
 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);
 }
예제 #8
0
파일: InitJVM.cs 프로젝트: TzarIvan/ratel
 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);
 }
예제 #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);
        }
예제 #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);
     }
 }
예제 #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);
            }
        }
예제 #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;
        }
예제 #13
0
파일: Timers.cs 프로젝트: TzarIvan/ratel
 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);
     }
 }
예제 #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);
        }
예제 #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;
     }
 }
예제 #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));
        }
예제 #17
0
 public static void debug(string message)
 {
     LogC.debug(message);
 }
예제 #18
0
 public static void info(string s)
 {
     LogC.info(s);
 }
예제 #19
0
 public static void err(string s)
 {
     LogC.err(s);
 }
예제 #20
0
파일: TestLogC.cs 프로젝트: TzarIvan/ratel
 public override void tearDown()
 {
     base.tearDown();
     LogC.setOut("Test", null, false);
 }
예제 #21
0
 public void initiate()
 {
     timerManager().everyMillis(waitMillis, publish, out timer);
     LogC.verbose(() => "initiated " + timer);
 }
예제 #22
0
 public static void debug <T>(T t, string name)
 {
     LogC.debug(t, name + paren(t.GetType().FullName + "#" + t.GetHashCode()));
 }