Beispiel #1
0
        /// <summary>
        /// Gets the entries.
        /// </summary>
        /// <param name="logFileName">Name of the log file.</param>
        /// <param name="page">The page.</param>
        /// <param name="searchQuery">The search query.</param>
        /// <returns></returns>
        public PagingResult <LogEntry> GetEntries(string logFileName, int?page = null, string searchQuery = null)
        {
            string location  = ApplicationSettings.Current.AlternateLogLocation;
            bool   showError = !string.IsNullOrWhiteSpace(location);
            PagingResult <LogEntry> entries = new PagingResult <LogEntry>();
            int pagingSize = ApplicationSettings.Current.DefaultPagingSize;

            this.TryExecute(
                () =>
            {
                ILogsClient client = this.factory.Create <ILogsClient>();
                entries            = client.GetLogEntries(logFileName, page, searchQuery, pagingSize);
            },
                () =>
            {
                if (!string.IsNullOrWhiteSpace(location))
                {
                    var logs = new List <LogEntry>();
                    logLoader.LoadLogs(logs, Path.Combine(ApplicationSettings.Current.AlternateLogLocation, logFileName));
                    entries = LogLoader.FilterLogs(logs, page, searchQuery, pagingSize);
                }
            },
                showError);

            return(entries);
        }
Beispiel #2
0
        public void LogLoader_LoadsValues_From_TwoFile()
        {
            LogLoader target    = new LogLoader(inputfile1, inputfile2);
            var       testvalue = target.SortedLines();

            Assert.AreEqual(testline, testvalue.Values[2].getLine());
        }
    private void Stop()
    {
        // if LogList is populated and we have a connection
        if (LogList.Count > 0 && DataAnalytics.GetConnectedState())
        {
            // For each element in LogList, send a request to DataAnalytics for Log Sending
            foreach (string temp in LogList)
            {
                DataAnalytics.AddLog(temp);
            }
        }

        // Else if LogList is populated and we do not have a connection
        else if (LogList.Count > 0 && DataAnalyticsStructure.GetConnectedState())
        {
            // For each element in LogList, send a request to LogLoader for Local Saving
            foreach (string temp in LogList)
            {
                LogLoader.WriteLogLocal(filePath, temp);
            }

            // Clear LogList
            LogList.Clear();
        }
    }
Beispiel #4
0
        public void LoadLogsFromXml_CanProcessAnXmlEntryCorrectlyWithThrowable()
        {
            LogLoader        loader  = new LogLoader(LogLoader.DefaultDate);
            IList <LogEntry> entries = new List <LogEntry>();
            string           xmlData = @"<log4j:event logger=""SACS.BusinessLayer.BusinessLogic.Application.AppManager"" timestamp=""1424119335723"" level=""ERROR"" thread=""8""><log4j:message>EmailService ServiceApp could not be initialized.</log4j:message><log4j:properties><log4j:data name=""log4jmachinename"" value=""User-PC"" /><log4j:data name=""log4japp"" value=""SACS.WindowsService.vshost.exe"" /><log4j:data name=""log4net:Identity"" value="""" /><log4j:data name=""log4net:UserName"" value=""User-PC\User"" /><log4j:data name=""log4net:HostName"" value=""User-PC"" /></log4j:properties><log4j:throwable>System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
   at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
   at System.Reflection.Assembly.LoadFile(String path)
   at SACS.BusinessLayer.BusinessLogic.Loader.DomainInitializer.FindEntryType(String assemblyPath) in e:\Development\SACS\Libraries\SACS.BusinessLayer\BusinessLogic\Loader\DomainInitializer.cs:line 44
   at SACS.BusinessLayer.BusinessLogic.Loader.DomainInitializer.FindEntryType(String assemblyPath)
   at SACS.BusinessLayer.BusinessLogic.Loader.DomainInitializer.GetEntryType(String assemblyPath) in e:\Development\SACS\Libraries\SACS.BusinessLayer\BusinessLogic\Loader\DomainInitializer.cs:line 31
   at SACS.BusinessLayer.BusinessLogic.Domain.ServiceAppDomain.Initialize() in e:\Development\SACS\Libraries\SACS.BusinessLayer\BusinessLogic\Domain\ServiceAppDomain.cs:line 186</log4j:throwable><log4j:locationInfo class=""SACS.BusinessLayer.BusinessLogic.Domain.ServiceAppDomain"" method=""Initialize"" file=""e:\Development\SACS\Libraries\SACS.BusinessLayer\BusinessLogic\Domain\ServiceAppDomain.cs"" line=""198"" /></log4j:event>";

            loader.LoadLogsFromXml(entries, LogLoader.AppendRoot(xmlData), false);

            Assert.AreEqual(1, entries.Count, "LogEntry count");
            Assert.IsTrue(entries[0].TimeStamp > new DateTime(1970, 1, 1), "The timestamp is wrong");
            Assert.AreEqual("ERROR", entries[0].Level, "Level value");
            Assert.AreEqual(LogImageType.Error, entries[0].ImageType, "LogImageType value");
            Assert.AreEqual("8", entries[0].Thread, "Thread value");
            Assert.AreEqual("EmailService ServiceApp could not be initialized.", entries[0].Message, "Message");
            Assert.AreEqual("User-PC", entries[0].MachineName, "Machine name");
            Assert.AreEqual("SACS.WindowsService.vshost.exe", entries[0].App, "App");
            Assert.AreEqual("User-PC\\User", entries[0].UserName, "User name");
            Assert.AreEqual("User-PC", entries[0].HostName, "Host name");
            Assert.IsTrue(entries[0].Throwable.Contains("System.IO.FileNotFoundException:"), "Throwable");
            Assert.AreEqual("SACS.BusinessLayer.BusinessLogic.Domain.ServiceAppDomain", entries[0].Class, "Class");
            Assert.AreEqual("Initialize", entries[0].Method, "Method");
            Assert.AreEqual("e:\\Development\\SACS\\Libraries\\SACS.BusinessLayer\\BusinessLogic\\Domain\\ServiceAppDomain.cs", entries[0].File, "File");
            Assert.AreEqual("198", entries[0].Line, "Line");
        }
        public async Task Load_TimeTesting_FewLines_End()
        {
            // Arrange
            LogLoader logDataLoader = new LogLoader(logDataParser, @"C:\Projekty\LoggingSW\vzorová data\bak550\7_5_2020");
            // Act
            var data = await logDataLoader.LoadAsyncOld(DateTime.Parse("18.5.2020 13:38:31"), DateTime.Parse("18.5.2020 13:38:33"));

            // Assert
        }
Beispiel #6
0
        public void Not_Really_A_Test()
        {
            var inputfilename1 = @"C:\Users\ra_do\AppData\Roaming\Firestorm_x64\radslns_hutchence\inkaku Capalini.txt";
            var inputfilename2 = @"G:\My Drive\SL\Chat\radslns_hutchence\radslns_hutchence\inkaku Capalini.txt";
            var outputfilename = @"G:\My Drive\SL\Chat\radslns_hutchence\inkaku Capalini.txt";
            var target         = new LogLoader(new FileInfo(inputfilename1), new FileInfo(inputfilename2));

            target.SaveBlendedLogs(outputfilename);
        }
Beispiel #7
0
        public void LoadLogsFromXml_CanHandleEmptyStrings()
        {
            LogLoader        loader  = new LogLoader(LogLoader.DefaultDate);
            IList <LogEntry> entries = new List <LogEntry>();

            loader.LoadLogsFromXml(entries, "    ", false);

            Assert.IsTrue(entries.Count == 0);
        }
        public async Task LoadAsync_MistoIenumerabluPouzivamVlastniKolekci_TimeTesting_TheWholeDocument()
        {
            // Arrange
            LogLoader logDataLoader = new LogLoader(logDataParser, @"C:\Projekty\LoggingSW\vzorová data\bak550\7_5_2020");
            // Act
            await logDataLoader.LoadAsyncData(DateTime.Parse("7.5.2020 13:18:56"), DateTime.Parse("18.5.2020 13:38:33"));

            // Assert
        }
        public async Task LoadAsync2_TimeTesting_TheWholeDocument()
        {
            // Arrange
            LogLoader logDataLoader = new LogLoader(logDataParser, @"C:\Projekty\LoggingSW\vzorová data\bak550\7_5_2020");
            // Act
            var data = await logDataLoader.LoadAsync(DateTime.Parse("7.5.2020 13:18:56"), DateTime.Parse("18.5.2020 13:38:33"));

            // Assert
        }
Beispiel #10
0
    /// <summary>
    /// GUI window function: browse and load CSV files
    /// </summary>
    private void CsvBrowser(int windowID)
    {
        // hide button
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("<", GUILayout.Width(30f)))
        {
            _windows.Pop();
        }
        // refresh files and folders
        if (GUILayout.Button("R", GUILayout.Width(30f)))
        {
            Refresh();
        }
        GUILayout.EndHorizontal();

        // go up one directory
        if (_subPath != "")
        {
            if (GUILayout.Button(".."))
            {
                _subPath = Directory.GetParent(_subPath).Name;
                Refresh();
            }
        }
        // list subdirectories
        for (int i = 0; i < _folders.Count; i++)
        {
            // enter subdirectory
            if (GUILayout.Button(_folders[i]))
            {
                _subPath += new DirectoryInfo(_folders[i]).Name;
                Refresh();
            }
        }
        if (LogLoader.loading)
        {
            GUILayout.Label("Loading...");
        }
        else
        {
            // list files
            for (int i = 0; i < _files.Count; i++)
            {
                // try paths from file
                if (GUILayout.Button(_files[i]))
                {
                    // change state when loading first data
                    if (BotNavSim.isIdle)
                    {
                        BotNavSim.state = BotNavSim.State.ViewingData;
                    }
                    LogLoader.LoadPaths(currentDir + "\\" + _files[i]);
                }
            }
        }
    }
Beispiel #11
0
    /// <summary>
    /// GUI window function: Display controls for loaded CSV files.
    /// </summary>
    private void Legend(int windowID)
    {
        // back button
        GUILayout.BeginHorizontal(GUILayout.Width(UI_Toolbar.I.innerWidth));
        if (GUILayout.Button("<", GUILayout.Width(30f)))
        {
            hidden = true;
        }
        if (GUILayout.Button("Load from CSV..."))
        {
            _windows.Push(CsvBrowser);
        }
        GUILayout.EndHorizontal();

        if (LogLoader.paths.Count < 1)
        {
            GUILayout.Label("No paths loaded.");
        }

        // list botpaths
        Color c = GUI.contentColor;

        for (int i = 0; i < LogLoader.paths.Count; i++)
        {
            GUILayout.BeginHorizontal();
            GUI.contentColor = LogLoader.paths[i].color;
            if (GUILayout.Button(LogLoader.paths[i].csvName))
            {
                LogLoader.paths[i].visible = !LogLoader.paths[i].visible;
                continue;
            }
            // highlight path if mouseover button
            // this event appears to be broken
            if (IsMouseOver())
            {
                LogLoader.paths[i].highlight = true;
            }
            else
            {
                LogLoader.paths[i].highlight = false;
            }
            // observe button
            if (GUILayout.Button("O"))
            {
                CamController.SetAreaOfInterest(LogLoader.paths[i]);
            }
            // unload path button
            if (GUILayout.Button("X"))
            {
                LogLoader.RemovePath(LogLoader.paths[i]);
            }
            GUILayout.EndHorizontal();
        }
        // reset content color
        GUI.contentColor = c;
    }
Beispiel #12
0
        public async Task LoadAsync_MistoIenumerabluPouzivamVlastniKolekci_ZakladniTest(DateTime pocatek, DateTime konec, int expected)
        {
            // Arrange
            LogLoader logDataLoader = new LogLoader(logDataParser, VZOROVA_CESTA);
            // Act
            var actual = (await logDataLoader.LoadAsyncData(pocatek, konec)).Count;

            // Assert
            Assert.Equal(expected, actual);
        }
Beispiel #13
0
        public void Create_2_LogEntries_From_A_CollectionOfLines()
        {
            var loglines = new LogLines();

            loglines.Add("[2020/09/16 09:50]  iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol");
            loglines.Add("[2020/09/16 09:44]  Rads (Radslns Hutchence): Good morning");
            LogLoader target = new LogLoader(loglines);

            Assert.AreEqual(2, target.Lines.Count);
        }
Beispiel #14
0
        public void Sort_LogEntries_BasedOn_Date()
        {
            var loglines = new LogLines();

            loglines.Add("[2020/09/16 09:50]  iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol");
            loglines.Add("[2020/09/16 09:44]  Rads (Radslns Hutchence): Good morning");
            LogLoader target    = new LogLoader(loglines);
            var       testvalue = target.SortedLines();

            Assert.AreEqual("2020/09/16 09:44", testvalue.Values[0].getDateTime());
        }
Beispiel #15
0
    /** Instance Methods **/

    /// <summary>
    /// Awake this instance.
    /// </summary>
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }
    }
Beispiel #16
0
        public async Task LoadAsync2_Fungujet(DateTime pocatek, DateTime konec, int expectedLength)
        {
            // Arrange
            LogLoader logDataLoader = new LogLoader(logDataParser, VZOROVA_CESTA);
            // Act
            var data = await logDataLoader.LoadAsync(pocatek, konec);

            int actualLength = data.First().Count();

            // Assert
            Assert.Equal(expectedLength, actualLength);
        }
Beispiel #17
0
        public void Sort_Two_LogEntries_For_The_Same_In_The_Order_They_Appear_In_TheLogs()
        {
            var loglines = new LogLines();

            testline = "[2020/09/16 09:50]  iמʞαʞů (inkaku Capalini): 2";
            loglines.Add("[2020/09/16 09:50]  iמʞαʞů (inkaku Capalini): cleaning out a desk is just not fun, hopefully their rearranging is beneficial for you lol");
            loglines.Add(testline);
            loglines.Add("[2020/09/16 09:44]  Rads (Radslns Hutchence): Good morning");
            LogLoader target    = new LogLoader(loglines);
            var       testvalue = target.SortedLines();

            Assert.AreEqual(testline, testvalue.Values[2].getLine());
        }
    public static void Log(string log)
    {
        // If there is no Connection, add it to the List
        if (!DataAnalytics.GetConnectedState())
        {
            LogList.Add(log);
        }

        // If there is a Connection, immediately send the log
        else
        {
            LogLoader.SendLog(LogList, log);
        }
    }
Beispiel #19
0
        public async Task LoadAsync_MistoIenumerabluPouzivamVlastniKolekci_ZakladniTest_OdpovidajiSiDatumy(string pocatek, string konec)
        {
            // Arrange
            LogLoader logDataLoader   = new LogLoader(logDataParser, VZOROVA_CESTA);
            var       expectedPocatek = DateTime.Parse(pocatek);
            var       expectedKonec   = DateTime.Parse(konec);
            // Act
            var data          = (await logDataLoader.LoadAsyncData(expectedPocatek, expectedKonec));
            var actualPocatek = data.Pocatek;
            var actualKonec   = data.Konec;

            // Assert
            Assert.True(actualPocatek == expectedPocatek && actualKonec == expectedKonec);
        }
Beispiel #20
0
        public void LoadLogsFromXml_CanSortDescending()
        {
            LogLoader        loader  = new LogLoader(LogLoader.DefaultDate);
            IList <LogEntry> entries = new List <LogEntry>();

            // 2 records
            string xmlData = @"<log4j:event logger=""Topshelf.HostFactory"" timestamp=""1424119928456"" level=""INFO"" thread=""8""><log4j:message>Configuration Result: SACS.Agent</log4j:message><log4j:properties><log4j:data name=""log4jmachinename"" value=""User-PC"" /><log4j:data name=""log4japp"" value=""SACS.WindowsService.vshost.exe"" /><log4j:data name=""log4net:Identity"" value="""" /><log4j:data name=""log4net:UserName"" value=""User-PC\User"" /><log4j:data name=""log4net:HostName"" value=""User-PC"" /></log4j:properties><log4j:locationInfo class=""Topshelf.Logging.Log4NetLogWriter"" method=""InfoFormat"" file="""" line=""0"" /></log4j:event>
<log4j:event logger=""Topshelf.HostFactory"" timestamp=""1424119938456"" level=""INFO"" thread=""8""><log4j:message>Configuration Result: SACS.Agent</log4j:message><log4j:properties><log4j:data name=""log4jmachinename"" value=""User-PC"" /><log4j:data name=""log4japp"" value=""SACS.WindowsService.vshost.exe"" /><log4j:data name=""log4net:Identity"" value="""" /><log4j:data name=""log4net:UserName"" value=""User-PC\User"" /><log4j:data name=""log4net:HostName"" value=""User-PC"" /></log4j:properties><log4j:locationInfo class=""Topshelf.Logging.Log4NetLogWriter"" method=""InfoFormat"" file="""" line=""0"" /></log4j:event>";

            // sort descending
            loader.LoadLogsFromXml(entries, LogLoader.AppendRoot(xmlData), true);

            Assert.AreEqual(2, entries.Count, "LogEntry count");
            Assert.AreEqual(2, entries[0].Item);
        }
Beispiel #21
0
    private static void ChangeState(State newState)
    {
        // exit old state behaviour
        switch (_state)
        {
        case State.Idle:
            break;

        case State.Simulating:
            Simulation.Exit();
            break;

        case State.ViewingData:
            LogLoader.Exit();
            break;

        case State.EditingRobot:
            break;

        case State.EditingEnvironment:
            break;
        }

        _state = newState;
        // enter new state behaviour
        switch (newState)
        {
        case State.Idle:
            break;

        case State.Simulating:
            Simulation.Enter();
            break;

        case State.ViewingData:
            LogLoader.Enter();
            break;

        case State.EditingRobot:
            break;

        case State.EditingEnvironment:
            break;
        }

        Debug.Log("BotNavSim: " + state.ToString());
    }
Beispiel #22
0
        public void LogLoader_WritesOut_LinesToAFile()
        {
            var       outputfilename = Path.GetTempFileName();
            LogLoader target         = new LogLoader(inputfile1, inputfile2);

            target.SaveBlendedLogs(outputfilename);
            var outputfile = new FileInfo(outputfilename);

            using (StreamReader sr = outputfile.OpenText())
            {
                string line = "";
                while (!sr.EndOfStream)
                {
                    line = sr.ReadLine();
                }
                Assert.AreEqual(testline, line);
            }
        }
Beispiel #23
0
        /// <summary>
        /// Gets the entries. GET /logs/[logname]?page=&amp;search=
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="page">The page.</param>
        /// <param name="search">The search.</param>
        /// <param name="size">The paging sizesize.</param>
        /// <returns></returns>
        /// <exception cref="System.Web.Http.HttpResponseException">Thrown when the log is not found.</exception>
        public PagingResult <LogEntry> GetEntries(string id, int?page = null, string search = null, int size = 0)
        {
            log.Debug(string.Format("(API) Log -> GetEntries - {0}", id));

            // id maps to the file name
            string           fullPath = GetFullLogPath(id);
            IList <LogEntry> logs     = new List <LogEntry>();

            try
            {
                logLoader.LoadLogs(logs, fullPath);
            }
            catch (FileNotFoundException)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            catch (IOException)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }

            return(LogLoader.FilterLogs(logs, page, search, size));
        }
Beispiel #24
0
        public void LoadLogsFromXml_CanProcessAnXmlEntryCorrectlyNoThrowable()
        {
            LogLoader        loader  = new LogLoader(LogLoader.DefaultDate);
            IList <LogEntry> entries = new List <LogEntry>();
            string           xmlData = @"<log4j:event logger=""Topshelf.HostFactory"" timestamp=""1424119928456"" level=""INFO"" thread=""8""><log4j:message>Configuration Result: SACS.Agent</log4j:message><log4j:properties><log4j:data name=""log4jmachinename"" value=""User-PC"" /><log4j:data name=""log4japp"" value=""SACS.WindowsService.vshost.exe"" /><log4j:data name=""log4net:Identity"" value="""" /><log4j:data name=""log4net:UserName"" value=""User-PC\User"" /><log4j:data name=""log4net:HostName"" value=""User-PC"" /></log4j:properties><log4j:locationInfo class=""Topshelf.Logging.Log4NetLogWriter"" method=""InfoFormat"" file="""" line=""0"" /></log4j:event>";

            loader.LoadLogsFromXml(entries, LogLoader.AppendRoot(xmlData), false);

            Assert.AreEqual(1, entries.Count, "LogEntry count");
            Assert.IsTrue(entries[0].TimeStamp > new DateTime(1970, 1, 1), "The timestamp is wrong");
            Assert.AreEqual("INFO", entries[0].Level, "Level value");
            Assert.AreEqual(LogImageType.Info, entries[0].ImageType, "LogImageType value");
            Assert.AreEqual("8", entries[0].Thread, "Thread value");
            Assert.AreEqual("Configuration Result: SACS.Agent", entries[0].Message, "Message");
            Assert.AreEqual("User-PC", entries[0].MachineName, "Machine name");
            Assert.AreEqual("SACS.WindowsService.vshost.exe", entries[0].App, "App");
            Assert.AreEqual("User-PC\\User", entries[0].UserName, "User name");
            Assert.AreEqual("User-PC", entries[0].HostName, "Host name");
            Assert.AreEqual("Topshelf.Logging.Log4NetLogWriter", entries[0].Class, "Class");
            Assert.AreEqual("InfoFormat", entries[0].Method, "Method");
            Assert.AreEqual("", entries[0].File, "File");
            Assert.AreEqual("0", entries[0].Line, "Line");
        }
 public static void GetLocalLogs()
 {
     LogList = LogLoader.GetLocalLogs(LogList);
 }