Exemple #1
0
        public void SetupHookLogging()
        {
            bool called = false;

            Yogi.SetupHookLogging(Yogi.Verbosity.Debug,
                                  (severity, timestamp, tid, file, line, comp, msg) =>
            {
                Assert.IsType <Yogi.Verbosity>(severity);
                Assert.Equal(Yogi.Verbosity.Warning, severity);
                Assert.IsType <Yogi.Timestamp>(timestamp);
                Assert.True(timestamp <= Yogi.CurrentTime);
                Assert.IsType <int>(tid);
                Assert.True(tid > 0);
                Assert.IsType <string>(file);
                Assert.NotEmpty(file);
                Assert.IsType <int>(line);
                Assert.True(line > 0);
                Assert.IsType <string>(comp);
                Assert.NotEmpty(comp);
                Assert.IsType <string>(msg);
                Assert.NotEmpty(msg);
                called = true;
            }
                                  );

            Yogi.AppLogger.Log(Yogi.Verbosity.Warning, "A warning");
            Assert.True(called);
        }
Exemple #2
0
        public void Log()
        {
            var logger = new Yogi.Logger("My logger");

            bool called = false;

            Yogi.SetupHookLogging(Yogi.Verbosity.Debug,
                                  (severity, timestamp, tid, file, line, comp, msg) =>
            {
                Assert.Equal(Yogi.Verbosity.Warning, severity);
                Assert.Equal("My logger", comp);
                Assert.Equal("Hey dude", msg);
                Assert.Equal(GetMyFilename(), file);
                Assert.True(line > 0);
                called = true;
            }
                                  );

            logger.Log(Yogi.Verbosity.Warning, "Hey dude");
            Assert.True(called);

            called = false;
            Yogi.SetupHookLogging(Yogi.Verbosity.Debug,
                                  (severity, timestamp, tid, file, line, comp, msg) =>
            {
                Assert.Equal("my file", file);
                Assert.Equal(123, line);
                called = true;
            }
                                  );

            logger.Log(Yogi.Verbosity.Warning, "Hey dude", file: "my file", line: 123);
            Assert.True(called);
        }