예제 #1
0
        private GetLogItem ReadSitecoreStarted([NotNull] StreamReader reader, [NotNull] FileInfo file, DateTime date, [NotNull] string line)
        {
            Debug.ArgumentNotNull(reader, nameof(reader));
            Debug.ArgumentNotNull(file, nameof(file));
            Debug.ArgumentNotNull(line, nameof(line));

            var result = new GetLogItem
            {
                LineNumber = LineNumber,
                Guid       = file.Name + "#" + LineNumber,
                File       = file
            };

            var    pos = 0;
            string threadNumber;
            string time;
            string category;

            var text = new StringBuilder();

            TextParser.ReadToken(line, ' ', ref pos, out threadNumber);
            TextParser.ReadToken(line, ' ', ref pos, out time);
            TextParser.ReadToken(line, ' ', ref pos, out category);

            ReadLine(reader);

            var l = ReadLine(reader);

            while (l != null && l.IndexOf("**********************************************************************", StringComparison.Ordinal) < 0)
            {
                pos = 0;
                TextParser.ReadToken(l, ' ', ref pos, out threadNumber);
                TextParser.ReadToken(l, ' ', ref pos, out time);
                TextParser.ReadToken(l, ' ', ref pos, out category);

                text.Append(l.Mid(pos));
                text.Append("\n");

                l = ReadLine(reader);
            }

            if (l != null)
            {
                ReadLine(reader);
            }

            result.Title       = "Sitecore Started";
            result.Link        = Url;
            result.Description = text.ToString();
            result.PubDate     = date + DateUtil.ParseTimeSpan(time);
            result.Category    = category;

            GetCategory(result);

            return(result);
        }
예제 #2
0
        private static void GetCategory([NotNull] GetLogItem item)
        {
            Debug.ArgumentNotNull(item, nameof(item));

            var title = item.Title;

            if (title.StartsWith("AUDIT"))
            {
                var n = title.IndexOf("):", StringComparison.Ordinal);
                if (n >= 0)
                {
                    item.UserName = title.Substring(7, n - 7);
                    item.Title    = title.Substring(n + 2);
                }
                else
                {
                    item.Title = title.Substring(6);
                }

                item.Category = "Audit";

                return;
            }

            if (title.StartsWith("DEBUG:"))
            {
                item.Title    = title.Substring(7);
                item.Category = "Debug";

                return;
            }

            switch (item.Category.ToUpperInvariant())
            {
            case "INFO":
                item.Category = "Information";
                return;

            case "WARN":
                item.Category = "Warning";
                return;

            case "ERROR":
                item.Category = "Error";
                return;

            case "FATAL":
                item.Category = "Fatal Error";
                return;

            case "DEBUG":
                item.Category = "Debug";
                return;
            }
        }
예제 #3
0
        private bool FilterItem([NotNull] GetLogItem item)
        {
            Debug.ArgumentNotNull(item, nameof(item));

            if (Categories != null)
            {
                var found = false;

                foreach (var text in Categories)
                {
                    if (item.Category.StartsWith(text.ToString(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    return(false);
                }
            }

            if (IncludeFilter != null)
            {
                var f = false;

                foreach (var text in IncludeFilter)
                {
                    if (item.Title.IndexOf(text, StringComparison.InvariantCultureIgnoreCase) >= 0)
                    {
                        f = true;
                        break;
                    }
                }

                if (!f)
                {
                    return(false);
                }
            }

            if (ExcludeFilter != null)
            {
                foreach (var text in ExcludeFilter)
                {
                    if (item.Title.IndexOf(text, StringComparison.InvariantCultureIgnoreCase) >= 0)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #4
0
        private void RenderItem([NotNull] XmlTextWriter output, [NotNull] GetLogItem item)
        {
            Debug.ArgumentNotNull(output, nameof(output));
            Debug.ArgumentNotNull(item, nameof(item));

            var description = string.Format("<div>{1}</div><div style=\"font-size:11px;margin-top:8px\"><i>{0}</i><span style=\"color:#999999\">, {2}, line {3}</span></div>", item.Category, item.Description, item.File.Name, item.LineNumber);

            description = description.Replace("\n", "<br />");

            output.WriteStartElement("item");

            output.WriteElementString("title", item.Title);
            output.WriteElementString("link", item.Link);
            output.WriteElementString("description", Clean(description));
            output.WriteElementString("pubDate", DateUtil.ToIsoDate(item.PubDate));
            output.WriteElementString("guid", item.Guid);
            output.WriteElementString("category", item.Category);

            output.WriteEndElement();
        }
예제 #5
0
        private GetLogItem ReadThreadItem([NotNull] StreamReader reader, [NotNull] FileInfo file, DateTime date, [NotNull] string line)
        {
            Debug.ArgumentNotNull(reader, nameof(reader));
            Debug.ArgumentNotNull(file, nameof(file));
            Debug.ArgumentNotNull(line, nameof(line));

            var result = new GetLogItem
            {
                LineNumber = LineNumber,
                Guid       = file.Name + "#" + LineNumber,
                File       = file
            };

            var    pos = 0;
            int    threadNumber;
            string time;
            string category;

            TextParser.ReadInt(line, ' ', ref pos, out threadNumber);
            TextParser.ReadToken(line, ' ', ref pos, out time);
            TextParser.ReadToken(line, ' ', ref pos, out category);

            var title = line.Mid(pos).Trim();

            if (string.IsNullOrEmpty(title))
            {
                return(null);
            }

            var description = ReadMore(reader);

            result.Title       = title;
            result.Link        = Url;
            result.Description = title + description;
            result.PubDate     = date + DateUtil.ParseTimeSpan(time);
            result.Category    = category;

            GetCategory(result);

            return(result);
        }
예제 #6
0
        private GetLogItem ReadSitecoreShutDown([NotNull] StreamReader reader, [NotNull] FileInfo file, DateTime date)
        {
            Debug.ArgumentNotNull(reader, nameof(reader));
            Debug.ArgumentNotNull(file, nameof(file));

            var result = new GetLogItem
            {
                LineNumber = LineNumber,
                Guid       = file.Name + "#" + LineNumber,
                File       = file
            };

            var line = ReadLine(reader);

            var    pos = 0;
            string thread;
            string time;
            string category;

            TextParser.ReadToken(line, ' ', ref pos, out thread);
            TextParser.ReadToken(line, ' ', ref pos, out time);
            TextParser.ReadToken(line, ' ', ref pos, out category);

            var title = line.Mid(pos).Trim();

            result.Title       = title;
            result.Link        = Url;
            result.Description = title;
            result.PubDate     = date + DateUtil.ParseTimeSpan(time);
            result.Category    = category;

            GetCategory(result);

            line = ReadLine(reader);
            if (line != null)
            {
                result.Description += "\n\n" + ReadUntilBlankLine(reader, line);
            }

            return(result);
        }