Beispiel #1
0
        public void TranslateEvent_should_prerender_message_with_trace_id()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent.WithProperty("traceContext", "guid"), true);

            log4netEvent.MessageObject.Should().Be("guid Hello, Vostok! You have 150 messages.");
            log4netEvent.RenderedMessage.Should().Be("guid Hello, Vostok! You have 150 messages.");
        }
Beispiel #2
0
        public void TranslateEvent_should_keep_original_event_timestamp()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.TimeStampUtc.Should().Be(vostokEvent.Timestamp.UtcDateTime);
            log4netEvent.TimeStamp.Should().Be(vostokEvent.Timestamp.LocalDateTime);
        }
        public static string GetLogfilePath(string logfile)
        {
            string        currentPath = Log4netHelpers.GetLogFileFolder("SynapseServer");
            DirectoryInfo directory   = new DirectoryInfo(currentPath);

            return(Path.Combine(currentPath, logfile));
        }
Beispiel #4
0
        public void TranslateEvent_should_prerender_message()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.MessageObject.Should().Be("Hello, Vostok! You have 150 messages.");
            log4netEvent.RenderedMessage.Should().Be("Hello, Vostok! You have 150 messages.");
        }
Beispiel #5
0
 public void TranslateLevel_should_correctly_translate_all_log_levels()
 {
     Log4netHelpers.TranslateLevel(LogLevel.Debug).Should().BeSameAs(Level.Debug);
     Log4netHelpers.TranslateLevel(LogLevel.Info).Should().BeSameAs(Level.Info);
     Log4netHelpers.TranslateLevel(LogLevel.Warn).Should().BeSameAs(Level.Warn);
     Log4netHelpers.TranslateLevel(LogLevel.Error).Should().BeSameAs(Level.Error);
     Log4netHelpers.TranslateLevel(LogLevel.Fatal).Should().BeSameAs(Level.Fatal);
 }
Beispiel #6
0
        public void TranslateEvent_should_populate_log4net_event_properties()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.Properties.Should().HaveCount(2);
            log4netEvent.Properties["User"].Should().Be("Vostok");
            log4netEvent.Properties["Count"].Should().Be(150);
        }
Beispiel #7
0
        public static string GetLogfilePath(string logfile)
        {
            string currentPath = Log4netHelpers.GetLogFileFolder("SynapseServer");

            if (!string.IsNullOrWhiteSpace(currentPath))
            {
                DirectoryInfo directory = new DirectoryInfo(currentPath);
                return(Path.Combine(currentPath, logfile));
            }
            else
            {
                return(null);
            }
        }
        public static List <AutoUpdaterMessage> FetchLogList()
        {
            string                 currentPath = Log4netHelpers.GetLogFileFolder("SynapseServer");
            DirectoryInfo          directory   = new DirectoryInfo(currentPath);
            IEnumerable <FileInfo> logs        = directory.GetFiles("*.log", SearchOption.TopDirectoryOnly)
                                                 .OrderByDescending(f => f.LastWriteTime);

            List <AutoUpdaterMessage> logFiles = new List <AutoUpdaterMessage>();

            foreach (FileInfo log in logs)
            {
                logFiles.Add(new AutoUpdaterMessage()
                {
                    TimeStamp = log.LastWriteTime, Message = log.Name
                });
            }

            return(logFiles);
        }
Beispiel #9
0
        public void TranslateEvent_should_set_correct_logger_repository_for_log4net_event()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.Repository.Should().BeSameAs(log4netLogger.Repository);
        }
Beispiel #10
0
        public void TranslateEvent_should_set_correct_logger_name_for_log4net_event()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.LoggerName.Should().Be("MyLogger");
        }
Beispiel #11
0
        public void TranslateEvent_should_correctly_translate_level()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.Level.Should().BeSameAs(Level.Warn);
        }
Beispiel #12
0
        public void TranslateEvent_should_set_log4net_event_exception()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.ExceptionObject.Should().BeSameAs(vostokEvent.Exception);
        }
Beispiel #13
0
        public void TranslateEvent_should_not_fix_log4net_event()
        {
            log4netEvent = Log4netHelpers.TranslateEvent(log4netLogger, vostokEvent);

            log4netEvent.Fix.Should().Be(FixFlags.None);
        }