Beispiel #1
0
        public static void Main(string[] args)
        {
            //Start of the project
            Validations validations = new Validations();

            if (!validations.checkForArgumentCount(args))
            {
                return;
            }

            CommandInput commandInput = new CommandInput();

            commandInput.getCommandinput(args);

            if (!validations.getInputDirectoryStatus(commandInput))
            {
                return;
            }

            ParseLogFile parseLogFile = new ParseLogFile();

            List <string> allLogs      = parseLogFile.parseFileToStringList(commandInput.logFilePath);
            List <string> requiredLogs = parseLogFile.getRequiredLogs(allLogs, commandInput.loglevel);

            ProcessLogcontent processLogcontent = new ProcessLogcontent();
            var csvContent = processLogcontent.getCsvCompliantContent(requiredLogs);

            CsvGeneration csvGeneration = new CsvGeneration();

            csvGeneration.createCsvFile(csvContent, commandInput.csvFilePath);
        }
Beispiel #2
0
        public List <ProcessLogcontent> getCsvCompliantContent(List <string> logLines)
        {
            List <ProcessLogcontent> CsvContents = new List <ProcessLogcontent>();

            foreach (var line in logLines)
            {
                try
                {
                    var csvContent = new ProcessLogcontent();
                    csvContent.Level       = csvContent.getLogLevel(line);
                    csvContent.Date        = csvContent.getdate(line);
                    csvContent.Time        = csvContent.getTime(line);
                    csvContent.Description = csvContent.getDescription(line);

                    CsvContents.Add(csvContent);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"{e.Message}");
                }
            }

            return(CsvContents);
        }