Пример #1
0
        public void logRecord_constructorPopulatesProcessNo()
        {
            logRecord b = new logRecord("test", loggerLevels.CRITICAL, "", argsTest, "");

            Process tempProcess = Process.GetCurrentProcess();

            Assert.AreEqual(tempProcess.Id, b.process);
        }
Пример #2
0
 public override bool log(logRecord record)
 {
     if (this.getlevel() <= record.levelEnum)
     {
         this.logAction(this.formatter.format(record));
         return(true);
     }
     return(false);
 }
Пример #3
0
        public void formatter_testDefaultConstructor()
        {
            string testMessage = "testLogger {0}, {1}";

            string[]  argsArray = new string[] { "test_args1", "test_args2" };
            formatter b         = new formatter();
            logRecord l         = new logRecord("formatter Test", loggerLevels.CRITICAL, testMessage, argsArray, "");

            Console.WriteLine(b.format(l));
            Assert.AreEqual(String.Format(testMessage, argsArray), b.format(l));
        }
Пример #4
0
        public string format(logRecord record)
        {
            formatter fmt = null;

            if (this.formatter != null)
            {
                fmt = this.formatter;
            }
            else
            {
                fmt = _defaultFormatter;
            }

            return(fmt.format(record));
        }
Пример #5
0
        public void formatter_properlyAddsLoggerName()
        {
            string testMessage = "testLogger {0}, {1}";

            string[]     argsArray  = new string[] { "test_args1", "test_args2" };
            loggerLevels testLevel  = loggerLevels.CRITICAL;
            string       loggerName = "formatter Test";

            formatter b = new formatter("{levelName}:{name}:{message}");
            logRecord l = new logRecord(loggerName, testLevel, testMessage, argsArray, "");

            string resultMessage = String.Format("{0}:{1}:{2}", testLevel, loggerName, String.Format(testMessage, argsArray));

            Console.WriteLine(b.format(l));
            Assert.AreEqual(resultMessage, b.format(l));
        }
Пример #6
0
 public override void emit(logRecord record)
 {
     string msg = this.format(record);
 }
Пример #7
0
 public abstract void emit(logRecord record);
Пример #8
0
 public abstract bool log(logRecord record_in);
Пример #9
0
        public void logRecord_constructorPopulatesLevelNo()
        {
            logRecord b = new logRecord("test", loggerLevels.CRITICAL, "", argsTest, "");

            Assert.AreEqual(50, b.levelNo);
        }
Пример #10
0
        public void logRecord_constructorPopulatesMsecs()
        {
            logRecord b = new logRecord("test", loggerLevels.CRITICAL, "", argsTest, "");

            Assert.AreEqual(b.created.Millisecond, b.msecs);
        }
Пример #11
0
        public void logRecord_constructorPopulatesCreated()
        {
            logRecord b = new logRecord("test", loggerLevels.CRITICAL, "", argsTest, "");

            Assert.IsNotNull(b.created);
        }