public new ParsingResult Analyze([NotNull] LogProcessorSettings settings)
            {
                Assert.ArgumentNotNull(settings, nameof(settings));
                var context = new ProcessContext
                {
                    Settings = settings
                };

                return(ParseLogsWrap(context, context.Logging));
            }
Exemple #2
0
        public static void ExtractMessagesFromFiles(IEnumerable <ACSLogFile> mLogsToProcess,
                                                    string directory, List <Message> messages, UIFilterSettings settUIFilters,
                                                    bool doCreateSeparateMessageLists, Action <string> uiSyncAction)
        {
            foreach (var logFile in mLogsToProcess)
            {
                settUIFilters.FilterRTSMMessages = (logFile.SourceType == SourceType.RTSM_in_thslog);

                var processorSettings = new LogProcessorSettings()
                {
                    LogFile = logFile, UIFS = settUIFilters, CreateSeparateMessageLists = doCreateSeparateMessageLists
                };

                var    lp                = new LogProcessor();
                string resultPath        = string.Empty;
                int    prevMessagesCount = messages.Count;
                try
                {
                    resultPath = lp.ProcessLogFile(directory, processorSettings, m => messages.Add(m));
                    var messagesProcessedCount = messages.Count - prevMessagesCount;
                    var updateStatusText       =
                        string.Format("Processed file {0}.{2}{1}{2}",
                                      logFile.LogFileName,
                                      messagesProcessedCount == 0
                            ? string.Format("No {0} messages found.", logFile.SourceType)
                            : string.Format("Parsed {0} {1} message(s).", messagesProcessedCount, logFile.SourceType),
                                      Environment.NewLine);

                    if (processorSettings.CreateSeparateMessageLists)
                    {
                        updateStatusText += string.Format("Generated file:{0}{1}{0}", Environment.NewLine, resultPath);
                    }

                    updateStatusText += Environment.NewLine;
                    uiSyncAction(updateStatusText);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(
                              string.Format("An error occured when processing file{0}{1}{2}{3}", logFile.LogFileName, Environment.NewLine, "Error:", ex)
                              , ex);
                }

                System.GC.Collect();
                GC.WaitForPendingFinalizers();
            }
        }
        public IEnumerable <ILogEntry> GetSitecoreLogEntries(LogLevel logLevel, DateTime start, DateTime end)
        {
            var cache = _SitecoreLogs;

            if (cache == null)
            {
                var logProcessorSettings = new LogProcessorSettings
                {
                    ConnectionSettings = new FileConnectionSettings(GetLogFilesByLimit()),
                    ReaderSettings     = new LogReaderSettings(string.Empty)
                };

                var logs = _LogProcessor.Analyze(logProcessorSettings);
                if (logs == null || logs.All == null)
                {
                    throw new LogFilesResourceNotAvailableException("Sitecore logs were not found, corrupted or their limit (200MB) has been exceeded during loading");
                }

                cache         = logs.All.Select(x => new LogEntryEx(x.IsNotNull("x"))).ToArray();
                _SitecoreLogs = cache;
            }

            return(logLevel.HasFlag(LogLevel.Debug) ? cache.Where(x => start <= x.Date && x.Date <= end) : cache.Where(x => x.Level.HasFlag(logLevel) && start <= x.Date && x.Date <= end));
        }