Exemplo n.º 1
0
    /// <summary>
    /// This function has to return the timestamp of the given log line.
    /// It takes a substring of the line (first 21 chars containing the date and the time) and converts this into a DateTime object.
    /// </summary>
    /// <param name="callback"></param>
    /// <param name="line"></param>
    /// <returns></returns>
    public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
    {
      
      if (line.Length < 21)
      {
        return DateTime.MinValue;
      }
      
      // A first check if this could be a valid date/time string. This is for performance reasons, because 
      // DateTime.ParseExact() is slow when receiving an invalid input.
      if (line[2] != '.' || line[5] != '.' || line[11] != ':' || line[14] != ':')
      {
        return DateTime.MinValue;
      }

      try
      {
        // Parse into a DateTime
        DateTime dateTime = DateTime.ParseExact(line.Substring(0, 21), DATETIME_FORMAT, this.cultureInfo);

        // Add the time offset before returning
        return dateTime.AddMilliseconds(this.timeOffset);
      }
      catch (Exception)
      {
        return DateTime.MinValue;
      }
    }
Exemplo n.º 2
0
		public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
		{
			string[] cols = SplitLine(callback, line);
			if (cols == null || cols.Length < 2)
			{
				return DateTime.MinValue;
			}
			if (cols[0].Length == 0 || cols[1].Length == 0)
			{
				return DateTime.MinValue;
			}
			FormatInfo formatInfo = DetermineDateTimeFormatInfo(line);
			if (formatInfo == null)
				return DateTime.MinValue;
			
			try
			{
				DateTime dateTime = DateTime.ParseExact(cols[0] + " " + cols[1], formatInfo.DateTimeFormat, formatInfo.CultureInfo);
				return dateTime;
			}
			catch (Exception)
			{
				return DateTime.MinValue;
			}
		}
Exemplo n.º 3
0
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line)
        {
            IColumnizedLogLine cols = SplitLine(callback, line);

            if (cols == null || cols.ColumnValues.Length < 8)
            {
                return(DateTime.MinValue);
            }

            if (cols.ColumnValues[2].FullValue.Length == 0)
            {
                return(DateTime.MinValue);
            }

            try
            {
                DateTime dateTime = DateTime.ParseExact(cols.ColumnValues[2].FullValue, "dd/MMM/yyyy:HH:mm:ss zzz",
                                                        new CultureInfo("en-US"));
                return(dateTime);
            }
            catch (Exception)
            {
                return(DateTime.MinValue);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This function has to return the timestamp of the given log line.
        /// It takes a substring of the line (first 21 chars containing the date and the time) and converts this into a DateTime object.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
        {
            if (line.Length < 21)
            {
                return(DateTime.MinValue);
            }

            // A first check if this could be a valid date/time string. This is for performance reasons, because
            // DateTime.ParseExact() is slow when receiving an invalid input.
            if (line[2] != '.' || line[5] != '.' || line[11] != ':' || line[14] != ':')
            {
                return(DateTime.MinValue);
            }

            try
            {
                // Parse into a DateTime
                DateTime dateTime = DateTime.ParseExact(line.Substring(0, 21), DATETIME_FORMAT, this.cultureInfo);

                // Add the time offset before returning
                return(dateTime.AddMilliseconds(this.timeOffset));
            }
            catch (Exception)
            {
                return(DateTime.MinValue);
            }
        }
Exemplo n.º 5
0
        public void Selected(ILogLineColumnizerCallback callback)
        {
            _columnList.Clear();

            var line = callback.GetLogLine(0);

            if (line != null)
            {
                var json = ParseJson(line);
                if (json != null)
                {
                    var fieldCount = json.Properties().Count();

                    for (var i = 0; i < fieldCount; ++i)
                    {
                        _columnList.Add(new JsonColumn(json.Properties().ToArray()[i].Name));
                    }
                }
                else
                {
                    _columnList.Add(_initialColumn);
                }
            }
            else
            {
                _columnList.Add(_initialColumn);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// This function has to return the timestamp of the given log line.
        /// It takes a substring of the line (between [ and ])
        /// and converts this into a DateTime object.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
        {
            if (line.Length < 24)
            {
                return(DateTime.MinValue);
            }

            int end = line.IndexOf(" CET");

            if (end == -1)
            {
                return(DateTime.MinValue);
            }

            String s = line.Substring(1, end - 1);

            // Parse into a DateTime

            DateTime dateTime;

            if (!DateTime.TryParseExact(s, DATETIME_FORMAT_IN, this.cultureInfo, DateTimeStyles.None, out dateTime))
            {
                return(DateTime.MinValue);
            }

            // Add the time offset before returning
            return(dateTime.AddMilliseconds(this.timeOffset));
        }
Exemplo n.º 7
0
        public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line)
        {
            ColumnizedLogLine logLine = new ColumnizedLogLine();

            logLine.ColumnValues = new IColumn[columns.Length];
            if (Regex != null)
            {
                var m = Regex.Match(line.FullLine);
                for (int i = m.Groups.Count - 1; i > 0; i--)
                {
                    logLine.ColumnValues[i - 1] = new Column
                    {
                        Parent    = logLine,
                        FullValue = m.Groups[i].Value
                    };
                }
            }
            else
            {
                IColumn colVal = new Column
                {
                    Parent    = logLine,
                    FullValue = line.FullLine
                };

                logLine.ColumnValues[0] = colVal;
            }
            logLine.LogLine = line;
            return(logLine);
        }
Exemplo n.º 8
0
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
        {
            var match = this.config.Regex.Match(line);

            DateTime timestamp;

            if (this.config.TimestampField.Length == 0 ||
                this.config.TimestampFormat.Length == 0 ||
                !match.Success ||
                !match.Groups[this.config.TimestampField].Success ||
                !DateTime.TryParseExact(
                    match.Groups[this.config.TimestampField].Value,
                    this.config.TimestampFormat,
                    CultureInfo.InvariantCulture,
                    DateTimeStyles.None, out timestamp))
            {
                return(DateTime.MinValue);
            }

            if (this.config.LocalTimestamps)
            {
                timestamp = timestamp.ToLocalTime();
            }

            timestamp = timestamp.AddMilliseconds(this.TimeOffset);

            return(timestamp);
        }
        public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line)
        {
            if (line.LineNumber == 0 || line.FullLine == EndOfLogMessage)
            {
                return(null);
            }

            var columns = new List <IColumn>();
            ColumnizedLogLine columnizedLogLine = new ColumnizedLogLine();

            columnizedLogLine.LogLine = line;

            var logParts = line.FullLine.Split(new string[] { StatsAndMessageSeperator }, StringSplitOptions.RemoveEmptyEntries);

            if (logParts.Length == 2)
            {
                var informationParts = logParts[0].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                var messagePart      = logParts[1];

                columns.AddRange(informationParts.ToList().Take(4).Select(p => GetColumn(columnizedLogLine, p)).ToList());
                columns.Add(GetColumn(columnizedLogLine, messagePart));
                columns.AddRange(informationParts.ToList().Skip(4).Take(3).Select(p => GetColumn(columnizedLogLine, p)).ToList());
            }
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    columns.Add(GetColumn(columnizedLogLine, string.Empty));
                }
                columns.Add(GetColumn(columnizedLogLine, line.FullLine));
            }

            columnizedLogLine.ColumnValues = columns.ToArray();
            return(columnizedLogLine);
        }
Exemplo n.º 10
0
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line)
        {
            IColumnizedLogLine cols = SplitLine(callback, line);

            if (cols == null || cols.ColumnValues == null || cols.ColumnValues.Length < 2)
            {
                return(DateTime.MinValue);
            }
            if (cols.ColumnValues[0].FullValue.Length == 0 || cols.ColumnValues[1].FullValue.Length == 0)
            {
                return(DateTime.MinValue);
            }
            FormatInfo formatInfo = _timeFormatDeterminer.DetermineDateTimeFormatInfo(line.FullLine);

            if (formatInfo == null)
            {
                return(DateTime.MinValue);
            }

            try
            {
                DateTime dateTime = DateTime.ParseExact(
                    cols.ColumnValues[0].FullValue + " " + cols.ColumnValues[1].FullValue, formatInfo.DateTimeFormat,
                    formatInfo.CultureInfo);
                return(dateTime);
            }
            catch (Exception)
            {
                return(DateTime.MinValue);
            }
        }
Exemplo n.º 11
0
        public FilterSelectorForm(IList <ILogLineColumnizer> existingColumnizerList, ILogLineColumnizer currentColumnizer, ILogLineColumnizerCallback callback)
        {
            SelectedColumnizer = currentColumnizer;
            _callback          = callback;
            InitializeComponent();
            filterComboBox.SelectedIndexChanged += OnFilterComboBoxSelectedIndexChanged;

            // for the currently selected columnizer use the current instance and not the template instance from
            // columnizer registry. This ensures that changes made in columnizer config dialogs
            // will apply to the current instance
            _columnizerList = new List <ILogLineColumnizer>();
            foreach (ILogLineColumnizer col in existingColumnizerList)
            {
                _columnizerList.Add(col.GetType() == SelectedColumnizer.GetType() ? SelectedColumnizer : col);
            }

            foreach (ILogLineColumnizer col in _columnizerList)
            {
                filterComboBox.Items.Add(col);
            }

            foreach (ILogLineColumnizer columnizer in _columnizerList)
            {
                if (columnizer.GetType() == SelectedColumnizer.GetType())
                {
                    filterComboBox.SelectedItem = columnizer;
                    break;
                }
            }
        }
Exemplo n.º 12
0
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
        {
            string[] cols = SplitLine(callback, line);
            if (cols == null || cols.Length < 2)
            {
                return(DateTime.MinValue);
            }
            if (cols[0].Length == 0 || cols[1].Length == 0)
            {
                return(DateTime.MinValue);
            }
            FormatInfo formatInfo = DetermineDateTimeFormatInfo(line);

            if (formatInfo == null)
            {
                return(DateTime.MinValue);
            }

            try
            {
                DateTime dateTime = DateTime.ParseExact(cols[0] + " " + cols[1], formatInfo.DateTimeFormat, formatInfo.CultureInfo);
                return(dateTime);
            }
            catch (Exception)
            {
                return(DateTime.MinValue);
            }
        }
Exemplo n.º 13
0
        public ILogLine GetLineTextForClipboard(string logLine, ILogLineColumnizerCallback callback)
        {
            Log4JLogLine line = new Log4JLogLine();

            line.FullLine   = logLine.Replace(separatorChar, '|');
            line.LineNumber = callback.GetLineNum();
            return(line);
        }
Exemplo n.º 14
0
        public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
        {
            var match = this.config.Regex.Match(line);

            return(match.Success
                ? this.SplitLinesToColumns(callback, line, match)
                : this.LineToDefaultColumn(line));
        }
Exemplo n.º 15
0
        /// <summary>
        /// Given a single line of the log file this function splits the line content into columns. The function returns
        /// a string array containing the split content.
        /// </summary>
        /// <param name="callback">Callback interface with functions which can be used</param>
        /// <param name="line">The line content to be split</param>
        /// <returns>The parsed columns</returns>
        public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
        {
            // 0         1         2         3         4         5         6         7         8         9         10        11        12        13        14        15        16
            // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
            // 2016-03-20 19:03:30.8642 INFO Call Site                                                          : <rest of line>

            var endPos            = dateTimeFormat.Length;
            var timeLen           = timeFormat.Length;
            var dateLen           = dateFormat.Length;
            var logEntryPrefixLen = 2;
            var cols = new string[5];

            // If the line is shorter than we expect, or doesn't contain a space delimiter where we expect it, don't attempt to parse it
            if (line.Length < 97 || line.Length > endPos && line[endPos] != ' ')
            {
                return(new string[] { string.Empty, string.Empty, string.Empty, string.Empty, line });
            }

            try
            {
                if (this.timeOffset != 0)
                {
                    var dateTime = DateTime.ParseExact(line.Substring(0, endPos), dateTimeFormat, CultureInfo.CurrentUICulture);
                    dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset));
                    var newDate = dateTime.ToString(dateTimeFormat, CultureInfo.CurrentUICulture);
                    cols[0] = newDate.Substring(0, dateLen);                 // date
                    cols[1] = newDate.Substring(dateLen + 1, timeLen);       // time
                }
                else
                {
                    cols[0] = line.Substring(0, dateLen);                 // date
                    cols[1] = line.Substring(dateLen + 1, timeLen);       // time
                }

                // Find the space which delimits the end of the log level field
                var startIndex = dateLen + 1 + timeLen + 1;
                var logLen     = line.IndexOf(' ', startIndex) - startIndex;

                // Find the colon which delimits the call site field
                startIndex = dateLen + 1 + timeLen + 1 + logLen + 1;
                var callSiteLen = line.IndexOf(':', startIndex) - startIndex;

                if (logLen < 1 || callSiteLen < 1)
                {
                    return(new string[] { string.Empty, string.Empty, string.Empty, string.Empty, line });
                }

                cols[2] = line.Substring(dateLen + 1 + timeLen + 1, logLen);                                        // log level
                cols[3] = line.Substring(dateLen + 1 + timeLen + 1 + logLen + 1, callSiteLen);                      // call site
                cols[4] = line.Substring(dateLen + 1 + timeLen + 1 + logLen + 1 + callSiteLen + logEntryPrefixLen); // rest of line
            }
            catch (Exception)
            {
                return(new string[] { string.Empty, string.Empty, string.Empty, string.Empty, line });
            }

            return(cols);
        }
 public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
 {
     string[] cols = new string[6] {
         "", "", "", "", "", ""
     };
     if (line.Length > 1024)
     {
         // spam
         line    = line.Substring(0, 1024);
         cols[4] = line;
         return(cols);
     }
     String[] res = Regex.Split(line, "\\|");
     //if (_lineRegex.IsMatch(line))
     if (true)
     {
         /*
          * Match match = _lineRegex.Match(line);
          * GroupCollection groups = match.Groups;
          * if (groups.Count == 9)
          * {
          *  cols[0] = groups[1].Value;
          *  cols[1] = groups[2].Value;
          *  cols[2] = groups[3].Value;
          *  cols[3] = groups[4].Value;
          *  cols[4] = groups[5].Value;
          *  cols[5] = groups[6].Value;
          *  cols[6] = groups[7].Value;
          *  cols[7] = groups[8].Value;
          * }
          * else
          * {
          *  cols[7] = line;
          * }
          */
         if (res.Length == 5)
         {
             cols[0] = res[0];
             cols[1] = res[1];
             cols[2] = res[2];
             String[] dateTime = Regex.Split(res[3], "\\s");
             cols[3] = dateTime[1];
             cols[4] = dateTime[2];
             cols[5] = res[4];
         }
         else
         {
             cols[4] = line;
         }
     }
     else
     {
         cols[4] = line;
     }
     return(cols);
 }
Exemplo n.º 17
0
        public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
        {
            string[] cols = new string[COLUMN_COUNT] {
                "", ""
            };

            // delete '[#|' and '|#]'
            if (line.StartsWith("[#|"))
            {
                line = line.Substring(3);
            }
            if (line.EndsWith("|#]"))
            {
                line = line.Substring(0, line.Length - 3);
            }

            // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
            // in colum 8 (the log message column). Date and time column will be left blank.
            if (line.Length < 28)
            {
                cols[1] = line;
            }
            else
            {
                try
                {
                    DateTime dateTime = GetTimestamp(callback, line);
                    if (dateTime == DateTime.MinValue)
                    {
                        cols = new string[COLUMN_COUNT] {
                            "", line
                        };
                    }
                    string newDate = dateTime.ToString(DATETIME_FORMAT_OUT);
                    cols[0] = newDate;
                }
                catch (Exception)
                {
                    cols[0] = "n/a";
                }

                string timestmp = cols[0];
                cols = GetColsFromLine(line);
                if (cols.Length != COLUMN_COUNT)
                {
                    cols = new string[COLUMN_COUNT] {
                        "", line
                    };
                }
                else
                {
                    cols[0] = timestmp;
                }
            }
            return(cols);
        }
Exemplo n.º 18
0
        public ILogLine GetLineTextForClipboard(string logLine, ILogLineColumnizerCallback callback)
        {
            GlassFishLogLine line = new GlassFishLogLine
            {
                FullLine   = logLine.Replace(separatorChar, '|'),
                LineNumber = callback.GetLineNum()
            };

            return(line);
        }
Exemplo n.º 19
0
        public override void Selected(ILogLineColumnizerCallback callback)
        {
            ColumnList.Clear();
            // Create column header with cached column list.

            foreach (var col in _tagDict.Keys)
            {
                ColumnList.Add(new JsonColumn(_tagDict[col]));
            }
        }
Exemplo n.º 20
0
        public ILogLine GetLineTextForClipboard(ILogLine logLine, ILogLineColumnizerCallback callback)
        {
            Log4JLogLine line = new Log4JLogLine
            {
                FullLine = logLine.FullLine.Replace(separatorChar, '|'),
                LineNumber = logLine.LineNumber
            };

            return line;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Given a single line of the logfile this function splits the line content into columns. The function returns
        /// a string array containing the splitted content.
        /// </summary>
        /// <remarks>
        /// This function is called by LogExpert for every line that has to be drawn in the grid view. The faster your code
        /// handles the splitting, the faster LogExpert can draw the grid view content.
        /// </remarks>
        /// <param name="callback">Callback interface with functions which can be used by the columnizer</param>
        /// <param name="line">The line content to be splitted</param>
        public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
        {
            // 0         1         2         3         4         5         6         7         8         9         10        11
            // 0123456789012345678901234567890
            // 16.05.08 15:07:15,328 this is a log message line

            string[] cols = new string[3] {
                "", "", ""
            };

            // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
            // in colum 2 (the log message column). Date and time column will be left blank.
            if (line.Length < 23)
            {
                cols[2] = line;
                return(cols);
            }

            // A first check if this could be a valid date/time string. This is for performance reasons, because
            // DateTime.ParseExact() is slow when receiving an invalid input.
            // If there's no valid date/time, the content will be returned in column 2. Date and time column will be left blank.
            if (line[2] != '.' || line[5] != '.' || line[11] != ':' || line[14] != ':')
            {
                cols[2] = line;
                return(cols);
            }

            // If the time offset is not 0 we have to do some more work:
            // - parse the date/time part of the log line
            // - add the time offset
            // - convert back to string
            if (this.timeOffset != 0)
            {
                try
                {
                    DateTime dateTime = DateTime.ParseExact(line.Substring(0, 21), DATETIME_FORMAT, this.cultureInfo);
                    dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset));
                    string newDate = dateTime.ToString(DATETIME_FORMAT);
                    cols[0] = newDate.Substring(0, 8);   // date
                    cols[1] = newDate.Substring(09, 12); // time
                }
                catch (Exception)
                {
                    cols[0] = "n/a";
                    cols[1] = "n/a";
                }
            }
            else
            {
                cols[0] = line.Substring(0, 8);  // date
                cols[1] = line.Substring(9, 12); // time
            }
            cols[2] = line.Substring(22);        // rest of line
            return(cols);
        }
Exemplo n.º 22
0
 public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
 {
     if (this.isValidCsv)
     {
         return(SplitCsvLine(line));
     }
     else
     {
         return(new string[] { line });
     }
 }
Exemplo n.º 23
0
        public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line)
        {
            ColumnizedLogLine columnizedLogLine = new ColumnizedLogLine();

            columnizedLogLine.LogLine = line; // Add the reference to the LogLine
            string[]      textData = line.FullLine.Split('|');
            List <Column> colData  = new List <Column>();

            if (textData.Length >= 6)
            {
                for (int i = 0; i < 5; i++)
                {
                    Column col = new Column
                    {
                        FullValue = textData[i],
                        Parent    = columnizedLogLine
                    };
                    colData.Add(col);
                }

                //The message is the last column
                Column msgCol = new Column
                {
                    FullValue = textData[textData.Length - 1],
                    Parent    = columnizedLogLine
                };
                colData.Add(msgCol);
            }
            else
            {
                //This is for log entries that extended to the next line(s)
                //Put all of it into the message
                for (int i = 0; i < columnCount - 1; i++)
                {
                    Column col = new Column
                    {
                        FullValue = string.Empty,
                        Parent    = columnizedLogLine
                    };
                    colData.Add(col);
                }

                Column msgCol = new Column
                {
                    FullValue = line.FullLine,
                    Parent    = columnizedLogLine
                };
                colData.Add(msgCol);
            }

            columnizedLogLine.ColumnValues = colData.ToArray();
            return(columnizedLogLine);
        }
Exemplo n.º 24
0
 public void Configure(ILogLineColumnizerCallback callback, string configDir)
 {
     string configPath = configDir + "\\log4jxmlcolumnizer.dat";
     Log4jXmlColumnizerConfigDlg dlg = new Log4jXmlColumnizerConfigDlg(this.config);
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         BinaryFormatter formatter = new BinaryFormatter();
         Stream fs = new FileStream(configPath, FileMode.Create, FileAccess.Write);
         formatter.Serialize(fs, this.config);
         fs.Close();
     }
 }
        public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line)
        {
            ColumnizedLogLine columnizedLogLine = new ColumnizedLogLine();

            columnizedLogLine.LogLine = line; // Add the reference to the LogLine
            Column[] columns = Column.CreateColumns(GetColumnCount(), columnizedLogLine);
            columnizedLogLine.ColumnValues = columns.Select(a => a as IColumn).ToArray();
            String[] tmp = SplitLine(callback, line.FullLine);

            for (int i = 0; i < columns.Length; i++)
            {
                columns[i].FullValue = tmp[i];
            }
            return(columnizedLogLine);
        }
Exemplo n.º 26
0
        public void Configure(ILogLineColumnizerCallback callback, string configDir)
        {
            RegexColumnizerConfigDialog d = new RegexColumnizerConfigDialog {
                Config = Config
            };

            if (d.ShowDialog() == DialogResult.OK)
            {
                var configFile = GetConfigFile(configDir);
                using (var w = new FileStream(configFile, FileMode.Create))
                {
                    xml.Serialize(w, d.Config);
                }
            }
        }
Exemplo n.º 27
0
        public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
        { // 0         1         2         3         4         5         6         7         8         9         10        11        12        13        14        15        16
          // 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
          // 03.01.2008 14:48:00.066 <rest of line>

            if (line.Length < 21)
            {
                return(new string[] { "", "", line });
            }
            string[]   cols       = new string[3];
            FormatInfo formatInfo = DetermineDateTimeFormatInfo(line);

            if (formatInfo == null)
            {
                cols[0] = cols[1] = "";
                cols[2] = line;
                return(cols);
            }
            int endPos  = formatInfo.DateTimeFormat.Length;
            int timeLen = formatInfo.TimeFormat.Length;
            int dateLen = formatInfo.DateFormat.Length;

            try
            {
                if (this.timeOffset != 0)
                {
                    DateTime dateTime = DateTime.ParseExact(line.Substring(0, endPos), formatInfo.DateTimeFormat, formatInfo.CultureInfo);
                    dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset));
                    string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo);
                    cols[0] = newDate.Substring(0, dateLen);           // date
                    cols[1] = newDate.Substring(dateLen + 1, timeLen); // time
                    cols[2] = line.Substring(endPos);                  // rest of line
                }
                else
                {
                    cols[0] = line.Substring(0, dateLen);           // date
                    cols[1] = line.Substring(dateLen + 1, timeLen); // time
                    cols[2] = line.Substring(endPos);               // rest of line
                }
            }
            catch (Exception)
            {
                cols[0] = "n/a";
                cols[1] = "n/a";
                cols[2] = line;
            }
            return(cols);
        }
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine logLine)
        {
            string temp = logLine.FullLine;

            // delete '[#|' and '|#]'
            if (temp.StartsWith("[#|"))
            {
                temp = temp.Substring(3);
            }

            if (temp.EndsWith("|#]"))
            {
                temp = temp.Substring(0, temp.Length - 3);
            }

            if (temp.Length < 28)
            {
                return(DateTime.MinValue);
            }

            int endIndex = temp.IndexOf(separatorChar, 1);

            if (endIndex > 28 || endIndex < 0)
            {
                return(DateTime.MinValue);
            }

            string value = temp.Substring(0, endIndex);

            try
            {
                // convert glassfish timestamp into a readable format:
                DateTime timestamp;
                if (DateTime.TryParseExact(value, DATETIME_FORMAT, cultureInfo,
                                           System.Globalization.DateTimeStyles.None, out timestamp))
                {
                    return(timestamp.AddMilliseconds(this.timeOffset));
                }
                else
                {
                    return(DateTime.MinValue);
                }
            }
            catch (Exception)
            {
                return(DateTime.MinValue);
            }
        }
Exemplo n.º 29
0
 public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
 {
     if (column == 2)
     {
         try
         {
             DateTime newDateTime = DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US"));
             DateTime oldDateTime = DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US"));
             long     mSecsOld    = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond;
             long     mSecsNew    = newDateTime.Ticks / TimeSpan.TicksPerMillisecond;
             this.timeOffset = (int)(mSecsNew - mSecsOld);
         }
         catch (FormatException)
         { }
     }
 }
Exemplo n.º 30
0
 /// <summary>
 /// This function is called if the user changes a value in a column (edit mode in the log view).
 /// The purpose if the function is to determine a new timestamp offset. So you have to handle the
 /// call only if the given column displays a timestamp.
 /// </summary>
 public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
 {
     if (column == 0)
     {
         try
         {
             DateTime newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT_OUT, this.cultureInfo);
             DateTime oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT_OUT, this.cultureInfo);
             long     mSecsOld    = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond;
             long     mSecsNew    = newDateTime.Ticks / TimeSpan.TicksPerMillisecond;
             this.timeOffset = (int)(mSecsNew - mSecsOld);
         }
         catch (FormatException)
         { }
     }
 }
Exemplo n.º 31
0
        public void Configure(ILogLineColumnizerCallback callback, string configDir)
        {
            var configPath = configDir + @"\Regexcolumnizer-" + this.name + "." + ".dat";

            var configDialog = new RegexColumnizerConfigDlg(this.config);

            if (configDialog.ShowDialog() == DialogResult.OK)
            {
                configDialog.Apply(this.config);
                using (var fs = new FileStream(configPath, FileMode.Create, FileAccess.Write))
                {
                    var formatter = new BinaryFormatter();
                    formatter.Serialize(fs, this.config);
                }
            }
        }
Exemplo n.º 32
0
        public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
        {
            string[] cols = new string[Log4jXmlColumnizer.COLUMN_COUNT] {
                "", "", "", "", "", "", "", "", ""
            };

            // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
            // in colum 8 (the log message column). Date and time column will be left blank.
            if (line.Length < 15)
            {
                cols[8] = line;
            }
            else
            {
                try
                {
                    DateTime dateTime = GetTimestamp(callback, line);
                    if (dateTime == DateTime.MinValue)
                    {
                        cols = new string[Log4jXmlColumnizer.COLUMN_COUNT] {
                            "", "", "", "", "", "", "", "", line
                        };
                    }
                    string newDate = dateTime.ToString(DATETIME_FORMAT);
                    cols[0] = newDate;
                }
                catch (Exception)
                {
                    cols[0] = "n/a";
                }

                string timestmp = cols[0];
                cols = GetColsFromLine(line);
                if (cols.Length != Log4jXmlColumnizer.COLUMN_COUNT)
                {
                    cols = new string[Log4jXmlColumnizer.COLUMN_COUNT] {
                        "", "", "", "", "", "", "", "", line
                    };
                }
                else
                {
                    cols[0] = timestmp;
                }
            }

            return(MapColumns(cols));
        }
Exemplo n.º 33
0
		public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
		{
			if (column == 2)
			{
				try
				{
					DateTime newDateTime = DateTime.ParseExact(value, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US"));
					DateTime oldDateTime = DateTime.ParseExact(oldValue, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US"));
					long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond;
					long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond;
					_timeOffset = (int)(mSecsNew - mSecsOld);
				}
				catch (FormatException)
				{
				}
			}
		}
Exemplo n.º 34
0
        /// <summary>
        /// This function has to return the timestamp of the given log line.
        /// It takes a substring of the line (between [ and ])
        /// and converts this into a DateTime object.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
        {
            if (line.Length < 18 || !Char.IsDigit(line, 0) || line[2] != '-' || line[11] != ':')
            {
            return DateTime.MinValue;
            }

            String s = line.Substring(0,18);

            // Parse into a DateTime

            DateTime dateTime;
            if (!DateTime.TryParseExact(s, DATETIME_FORMAT_IN, this.cultureInfo, DateTimeStyles.None, out dateTime))
            return DateTime.MinValue;

            // Add the time offset before returning
            return dateTime.AddMilliseconds(this.timeOffset);
        }
Exemplo n.º 35
0
		public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
		{
			string[] cols = SplitLine(callback, line);
			if (cols == null || cols.Length < 8)
			{
				return DateTime.MinValue;
			}
			if (cols[2].Length == 0)
			{
				return DateTime.MinValue;
			}
			try
			{
				DateTime dateTime = DateTime.ParseExact(cols[2], "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US"));
				return dateTime;
			}
			catch (Exception)
			{
				return DateTime.MinValue;
			}
		}
Exemplo n.º 36
0
		public static bool TestFilterCondition(FilterParams filterParams, string line, ILogLineColumnizerCallback columnizerCallback)
		{
			if (filterParams.lastLine.Equals(line))
			{
				return filterParams.lastResult;
			}

			bool match = TestFilterMatch(filterParams, line, columnizerCallback);
			filterParams.lastLine = line;

			if (filterParams.isRangeSearch)
			{
				if (!filterParams.isInRange)
				{
					if (match)
					{
						filterParams.isInRange = true;
					}
				}
				else
				{
					if (!match)
					{
						match = true;
					}
					else
					{
						filterParams.isInRange = false;
					}
				}
			}
			if (filterParams.isInvert)
			{
				match = !match;
			}
			filterParams.lastResult = match;
			return match;
		}
Exemplo n.º 37
0
    /// <summary>
    /// This function has to return the timestamp of the given log line.
    /// It takes a substring of the line (between [ and ])
    /// and converts this into a DateTime object.
    /// </summary>
    /// <param name="callback"></param>
    /// <param name="line"></param>
    /// <returns></returns>
    public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
    {
      
      if (line.Length < 24)
      {
        return DateTime.MinValue;
      }
      
      int end = line.IndexOf(" CET");
      if (end == -1)
        return DateTime.MinValue;

      String s = line.Substring(1, end - 1);

      // Parse into a DateTime
      
      DateTime dateTime;
      if (!DateTime.TryParseExact(s, DATETIME_FORMAT_IN, this.cultureInfo, DateTimeStyles.None, out dateTime))
        return DateTime.MinValue;

      // Add the time offset before returning
      return dateTime.AddMilliseconds(this.timeOffset);
    }
Exemplo n.º 38
0
		public FilterSelectorForm(IList<ILogLineColumnizer> existingColumnizerList, ILogLineColumnizer currentColumnizer, ILogLineColumnizerCallback callback)
		{
			this.selectedColumnizer = currentColumnizer;
			this.callback = callback;
			InitializeComponent();
			this.filterComboBox.SelectedIndexChanged += new EventHandler(filterComboBox_SelectedIndexChanged);

			// for the currently selected columnizer use the current instance and not the template instance from
			// columnizer registry. This ensures that changes made in columnizer config dialogs
			// will apply to the current instance
			this.columnizerList = new List<ILogLineColumnizer>();
			foreach (ILogLineColumnizer col in existingColumnizerList)
			{
				if (col.GetType().Equals(this.selectedColumnizer.GetType()))
				{
					this.columnizerList.Add(this.selectedColumnizer);
				}
				else
				{
					this.columnizerList.Add(col);
				}
			}
			foreach (ILogLineColumnizer col in this.columnizerList)
			{
				this.filterComboBox.Items.Add(col);
			}

			foreach (ILogLineColumnizer columnizer in this.columnizerList)
			{
				if (columnizer.GetType().Equals(this.selectedColumnizer.GetType()))
				{
					this.filterComboBox.SelectedItem = columnizer;
					break;
				}
			}
		}
Exemplo n.º 39
0
 public void Selected(ILogLineColumnizerCallback callback)
 {
   if (this.isValidCsv) // see PreProcessLine()
   {
     this.columnList.Clear();
     string line = this.config.hasFieldNames ? this.firstLine : callback.GetLogLine(0);
     int i = 1;
     if (line != null)
     {
       string[] fields = SplitCsvLine(line);
       foreach (string field in fields)
       {
         if (this.config.hasFieldNames)
           this.columnList.Add(new CsvColumn(field));
         else
           this.columnList.Add(new CsvColumn("Column " + (i++)));
       }
     }
   }
 }
Exemplo n.º 40
0
 public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
 {
   throw new NotImplementedException();
 }
Exemplo n.º 41
0
 public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
 {
   throw new NotImplementedException();
 }
Exemplo n.º 42
0
        /// <summary>
        /// Given a single line of the logfile this function splits the line content into columns. The function returns 
        /// a string array containing the splitted content.
        /// </summary>
        /// <remarks>
        /// This function is called by LogExpert for every line that has to be drawn in the grid view. The faster your code
        /// handles the splitting, the faster LogExpert can draw the grid view content.
        /// </remarks>
        /// <param name="callback">Callback interface with functions which can be used by the columnizer</param>
        /// <param name="line">The line content to be splitted</param>
        public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
        {
            string[] cols = new string[7] { "", "", "", "", "", "", ""};

             /*     if (line.Length < 20)
              {
              cols[5] = "KRATKE";
              return null;
              }*/

              int start = 0, end = 0;
              int levelOffset = 0;

              // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
              // in colum 1 (the log message column). Timestamp column will be left blank.
              if (line.Length < 18 || !Char.IsDigit(line, 0) || line[2] != '-' || line[11] != ':')
              {
              cols[0] = lastTime;
              cols[1] = lastLevel;
              cols[2] = lastClass;
              }
              else
              {
              //timestamp
              cols[0] = line.Substring(0, 18);
              lastTime = cols[0];

              // level
              if (line.Substring(18, 1).Equals(":"))
              {
              // eclipse output
              // 11-23 11:52:44.962: D/
              cols[1] = line.Substring(20, 1);
              levelOffset = 22;
              }
              else
              {
              // logcat -v time
              // 11-23 11:52:44.962 D/
              cols[1] = line.Substring(19, 1);
              levelOffset = 21;
              }
              lastLevel = cols[1];

              end = line.IndexOf('(', levelOffset);

              // skip packages in class name:
              // com.company.app.FooClass
              //                 ^
              start = line.LastIndexOf('.', end, end - levelOffset) + 1;
              if (start == 0)
              {
              start = levelOffset;
              }

              // class
              cols[2] = line.Substring(start, end - start);
              lastClass = cols[2];

              start = end + 1;
              end = line.IndexOf(')', start);

              // TID
              cols[6] = line.Substring(start, end - start).Trim();
              start = end + 3;
              }

              end = line.LastIndexOf('[');

              if (line[line.Length - 1] == ']' && end != -1)
              {
              Boolean stackTrace = false;
              if (line.Substring(start, 5).Equals("\tat ["))
              {
              stackTrace = true;
              }
              else
              {
              cols[5] = line.Substring(start, end - start);
              }
              start = line.LastIndexOf('.', line.Length -2 , line.Length - end - 2)+1;

              if (start == 0)
              {
              start = end + 1;
              }

              end = line.LastIndexOf(':');
              cols[3] = line.Substring(start, end - start);
              cols[4] = line.Substring(end + 1, line.Length - end - 2);

              if(stackTrace)
              {
              cols[5] = "\tat " + cols[2] + '.' + cols[3] + ':' + cols[4];
              }
              }
              else
              {
              cols[5] = line.Substring(start);
              }

              return cols;
        }
Exemplo n.º 43
0
 public string GetLineTextForClipboard(string logLine, ILogLineColumnizerCallback callback)
 {
   return logLine.Replace(separatorChar, '|');
 }
Exemplo n.º 44
0
    public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
    {
      // delete '[#|' and '|#]'
      if (line.StartsWith("[#|"))
        line = line.Substring(3);
      if (line.EndsWith("|#]"))
        line = line.Substring(0, line.Length - 3);

      if (line.Length < 28)
      {
        return DateTime.MinValue;
      }

      int endIndex = line.IndexOf(separatorChar, 1);
      if (endIndex > 28 || endIndex < 0)
      {
        return DateTime.MinValue;
      }
      string value = line.Substring(0, endIndex);

      try
      {
        // convert glassfish timestamp into a readable format:
        DateTime timestamp;
        if (DateTime.TryParseExact(value, DATETIME_FORMAT, cultureInfo, System.Globalization.DateTimeStyles.None, out timestamp))
        {
          return timestamp.AddMilliseconds(this.timeOffset);
        }
        else
        {
          return DateTime.MinValue;
        }
      }
      catch (Exception)
      {
        return DateTime.MinValue;
      }
    }
Exemplo n.º 45
0
    public DateTime GetTimestamp(ILogLineColumnizerCallback callback, string line)
    {
      if (line.Length < 15)
      {
        return DateTime.MinValue;
      }

      int endIndex = line.IndexOf(separatorChar, 1);
      if (endIndex > 20 || endIndex < 0)
      {
        return DateTime.MinValue;
      }
      string value = line.Substring(0, endIndex);

      try
      {
        // convert log4j timestamp into a readable format:
        long timestamp;
        if (long.TryParse(value, out timestamp))
        {
          // Add the time offset before returning
          DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
          dateTime = dateTime.AddMilliseconds(timestamp);
          if (this.config.localTimestamps)
            dateTime = dateTime.ToLocalTime();
          return dateTime.AddMilliseconds(this.timeOffset);
        }
        else
        {
          return DateTime.MinValue;
        }
      }
      catch (Exception)
      {
        return DateTime.MinValue;
      }
    }
Exemplo n.º 46
0
    public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
    {
      string[] cols = new string[Log4jXmlColumnizer.COLUMN_COUNT] { "", "", "", "", "", "", "", "", "" };

      // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
      // in colum 8 (the log message column). Date and time column will be left blank.
      if (line.Length < 15)
      {
        cols[8] = line;
      }
      else
      {
        try
        {
          DateTime dateTime = GetTimestamp(callback, line);
          if (dateTime == DateTime.MinValue)
          {
            cols = new string[Log4jXmlColumnizer.COLUMN_COUNT] { "", "", "", "", "", "", "", "", line };
          }
          string newDate = dateTime.ToString(DATETIME_FORMAT);
          cols[0] = newDate;
        }
        catch (Exception)
        {
          cols[0] = "n/a";
        }

        string timestmp = cols[0];
        cols = GetColsFromLine(line);
        if (cols.Length != Log4jXmlColumnizer.COLUMN_COUNT)
        {
          cols = new string[Log4jXmlColumnizer.COLUMN_COUNT]{"", "", "", "", "", "", "", "", line};
        }
        else
        {
          cols[0] = timestmp;
        }
      }

      return MapColumns(cols);
    }
Exemplo n.º 47
0
		public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
		{
			if (column == 1)
			{
				try
				{
					FormatInfo formatInfo = DetermineTimeFormatInfo(oldValue);
					if (formatInfo == null)
						return;
					DateTime newDateTime = DateTime.ParseExact(value, formatInfo.TimeFormat, formatInfo.CultureInfo);
					DateTime oldDateTime = DateTime.ParseExact(oldValue, formatInfo.TimeFormat, formatInfo.CultureInfo);
					long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond;
					long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond;
					this.timeOffset = (int)(mSecsNew - mSecsOld);
				}
				catch (FormatException)
				{
				}
			}
		}
Exemplo n.º 48
0
		public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
		{ // 0         1         2         3         4         5         6         7         8         9         10        11        12        13        14        15        16
			// 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
			// 03.01.2008 14:48:00.066 <rest of line>
			if (line.Length < 21)
			{
				return new string[] { "", "", line };
			}
			string[] cols = new string[3];
			FormatInfo formatInfo = DetermineDateTimeFormatInfo(line);
			if (formatInfo == null)
			{
				cols[0] = cols[1] = "";
				cols[2] = line;
				return cols;
			}
			int endPos = formatInfo.DateTimeFormat.Length;
			int timeLen = formatInfo.TimeFormat.Length;
			int dateLen = formatInfo.DateFormat.Length;
			try
			{
				if (this.timeOffset != 0)
				{
					DateTime dateTime = DateTime.ParseExact(line.Substring(0, endPos), formatInfo.DateTimeFormat, formatInfo.CultureInfo);
					dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset));
					string newDate = dateTime.ToString(formatInfo.DateTimeFormat, formatInfo.CultureInfo);
					cols[0] = newDate.Substring(0, dateLen);         // date
					cols[1] = newDate.Substring(dateLen + 1, timeLen);   // time
					cols[2] = line.Substring(endPos);           // rest of line
				}
				else
				{
					cols[0] = line.Substring(0, dateLen);             // date
					cols[1] = line.Substring(dateLen + 1, timeLen);   // time
					cols[2] = line.Substring(endPos);                 // rest of line
				}
			}
			catch (Exception)
			{
				cols[0] = "n/a";
				cols[1] = "n/a";
				cols[2] = line;
			}
			return cols;
		}
Exemplo n.º 49
0
		public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
		{
			string[] cols = new string[8] { "", "", "", "", "", "", "", "" };
			if (line.Length > 1024)
			{
				// spam 
				line = line.Substring(0, 1024);
				cols[3] = line;
				return cols;
			}
			// 0         1         2         3         4         5         6         7         8         9         10        11        12        13        14        15        16
			// anon-212-34-174-126.suchen.de - - [08/Mar/2008:00:41:10 +0100] "GET /wiki/index.php?title=Bild:Poster_small.jpg&printable=yes&printable=yes HTTP/1.1" 304 0 "http://www.captain-kloppi.de/wiki/index.php?title=Bild:Poster_small.jpg&printable=yes" "gonzo1[P] +http://www.suchen.de/faq.html" 

			if (_lineRegex.IsMatch(line))
			{
				Match match = _lineRegex.Match(line);
				GroupCollection groups = match.Groups;
				if (groups.Count == 10)
				{
					cols[0] = groups[1].Value;
					cols[1] = groups[3].Value;
					cols[3] = groups[5].Value;
					cols[4] = groups[6].Value;
					cols[5] = groups[7].Value;
					cols[6] = groups[8].Value;
					cols[7] = groups[9].Value;

					string dateTimeStr = groups[4].Value.Substring(1, 26);

					// dirty probing of date/time format (much faster than DateTime.ParseExact()
					if (dateTimeStr[2] == '/' && dateTimeStr[6] == '/' && dateTimeStr[11] == ':')
					{
						if (_timeOffset != 0)
						{
							try
							{
								DateTime dateTime = DateTime.ParseExact(dateTimeStr, "dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US"));
								dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, _timeOffset));
								string newDate = dateTime.ToString("dd/MMM/yyyy:HH:mm:ss zzz", new CultureInfo("en-US"));
								cols[2] = newDate;
							}
							catch (Exception)
							{
								cols[2] = "n/a";
							}
						}
						else
						{
							cols[2] = dateTimeStr;
						}
					}
					else
					{
						cols[2] = dateTimeStr;
					}
				}
			}
			else
			{
				cols[3] = line;
			}
			return cols;
		}
Exemplo n.º 50
0
		private static bool TestFilterMatch(FilterParams filterParams, string line, ILogLineColumnizerCallback columnizerCallback)
		{
			string lowerSearchText;
			string searchText;
			Regex rex;
			if (filterParams.isInRange)
			{
				lowerSearchText = filterParams.lowerRangeSearchText;
				searchText = filterParams.rangeSearchText;
				rex = filterParams.rangeRex;
			}
			else
			{
				lowerSearchText = filterParams.lowerSearchText;
				searchText = filterParams.searchText;
				rex = filterParams.rex;
			}

			if (searchText == null || lowerSearchText == null || searchText.Length == 0)
			{
				return false;
			}

			if (filterParams.columnRestrict)
			{
				string[] columns = filterParams.currentColumnizer.SplitLine(columnizerCallback, line);
				bool found = false;
				foreach (int colIndex in filterParams.columnList)
				{
					if (colIndex < columns.Length) // just to be sure, maybe the columnizer has changed anyhow
					{
						if (columns[colIndex].Trim().Length == 0)
						{
							if (filterParams.emptyColumnUsePrev)
							{
								string prevValue = (string)filterParams.lastNonEmptyCols[colIndex];
								if (prevValue != null)
								{
									if (TestMatchSub(filterParams, prevValue, lowerSearchText, searchText, rex, filterParams.exactColumnMatch))
									{
										found = true;
									}
								}
							}
							else if (filterParams.emptyColumnHit)
							{
								return true;
							}
						}
						else
						{
							filterParams.lastNonEmptyCols[colIndex] = columns[colIndex];
							if (TestMatchSub(filterParams, columns[colIndex], lowerSearchText, searchText, rex, filterParams.exactColumnMatch))
							{
								found = true;
							}
						}
					}
				}
				return found;
			}
			else
			{
				return TestMatchSub(filterParams, line, lowerSearchText, searchText, rex, false);
			}
		}
Exemplo n.º 51
0
 public void DeSelected(ILogLineColumnizerCallback callback)
 { 
   // nothing to do 
 }
Exemplo n.º 52
0
    /// <summary>
    /// Given a single line of the logfile this function splits the line content into columns. The function returns 
    /// a string array containing the splitted content.
    /// </summary>
    /// <remarks>
    /// This function is called by LogExpert for every line that has to be drawn in the grid view. The faster your code
    /// handles the splitting, the faster LogExpert can draw the grid view content.
    /// </remarks>
    /// <param name="callback">Callback interface with functions which can be used by the columnizer</param>
    /// <param name="line">The line content to be splitted</param>
    public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
    {
      // 0         1         2         3         4         5         6         7         8         9         10        11 
      // 0123456789012345678901234567890
      // 16.05.08 15:07:15,328 this is a log message line

      string[] cols = new string[3] { "", "", "" };

      // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
      // in colum 2 (the log message column). Date and time column will be left blank.
      if (line.Length < 23)
      {
        cols[2] = line;
        return cols;
      }

      // A first check if this could be a valid date/time string. This is for performance reasons, because 
      // DateTime.ParseExact() is slow when receiving an invalid input.
      // If there's no valid date/time, the content will be returned in column 2. Date and time column will be left blank.
      if (line[2] != '.' || line[5] != '.' || line[11] != ':' || line[14] != ':')
      {
        cols[2] = line;
        return cols;
      }

      // If the time offset is not 0 we have to do some more work:
      // - parse the date/time part of the log line
      // - add the time offset
      // - convert back to string
      if (this.timeOffset != 0)
      {
        try
        {
          DateTime dateTime = DateTime.ParseExact(line.Substring(0, 21), DATETIME_FORMAT, this.cultureInfo);
          dateTime = dateTime.Add(new TimeSpan(0, 0, 0, 0, this.timeOffset));
          string newDate = dateTime.ToString(DATETIME_FORMAT);
          cols[0] = newDate.Substring(0, 8);    // date
          cols[1] = newDate.Substring(09, 12);   // time
        }
        catch (Exception)
        {
          cols[0] = "n/a";
          cols[1] = "n/a";
        }
      }
      else
      {
        cols[0] = line.Substring(0, 8);    // date
        cols[1] = line.Substring(9, 12);   // time
      }
      cols[2] = line.Substring(22);    // rest of line
      return cols;
    }
Exemplo n.º 53
0
 public void Configure(ILogLineColumnizerCallback callback, string configDir)
 {
   string configPath = configDir + "\\csvcolumnizer.dat";
   CsvColumnizerConfigDlg dlg = new CsvColumnizerConfigDlg(this.config);
   if (dlg.ShowDialog() == DialogResult.OK)
   {
     BinaryFormatter formatter = new BinaryFormatter();
     Stream fs = new FileStream(configPath, FileMode.Create, FileAccess.Write);
     formatter.Serialize(fs, this.config);
     fs.Close();
     Selected(callback);
   }
 }
Exemplo n.º 54
0
		public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
		{
		}
Exemplo n.º 55
0
 public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
 {
   if (column == 0)
   {
     try
     {
       DateTime newDateTime = DateTime.ParseExact(value, DATETIME_FORMAT_OUT, this.cultureInfo);
       DateTime oldDateTime = DateTime.ParseExact(oldValue, DATETIME_FORMAT_OUT, this.cultureInfo);
       long mSecsOld = oldDateTime.Ticks / TimeSpan.TicksPerMillisecond;
       long mSecsNew = newDateTime.Ticks / TimeSpan.TicksPerMillisecond;
       this.timeOffset = (int)(mSecsNew - mSecsOld);
     }
     catch (FormatException)
     { }
   }
 }
Exemplo n.º 56
0
		public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
		{
			return new string[] { line };
		}
Exemplo n.º 57
0
    public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
    {
      string[] cols = new string[COLUMN_COUNT] { "", ""};

      // delete '[#|' and '|#]'
      if (line.StartsWith("[#|"))
        line = line.Substring(3);
      if (line.EndsWith("|#]"))
        line = line.Substring(0, line.Length - 3);

      // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
      // in colum 8 (the log message column). Date and time column will be left blank.
      if (line.Length < 28)
      {
        cols[1] = line;
      }
      else
      {
        try
        {
          DateTime dateTime = GetTimestamp(callback, line);
          if (dateTime == DateTime.MinValue)
          {
            cols = new string[COLUMN_COUNT] { "", line };
          }
          string newDate = dateTime.ToString(DATETIME_FORMAT_OUT);
          cols[0] = newDate;
        }
        catch (Exception)
        {
          cols[0] = "n/a";
        }

        string timestmp = cols[0];
        cols = GetColsFromLine(line);
        if (cols.Length != COLUMN_COUNT)
        {
          cols = new string[COLUMN_COUNT]{"", line};
        }
        else
        {
          cols[0] = timestmp;
        }
      }
      return cols;
    }
Exemplo n.º 58
0
 public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
 {
   if (this.isValidCsv)
   {
     return SplitCsvLine(line);
   }
   else
   {
     return new string[] { line };
   }
 }
Exemplo n.º 59
0
    /// <summary>
    /// Given a single line of the logfile this function splits the line content into columns. The function returns 
    /// a string array containing the splitted content.
    /// </summary>
    /// <remarks>
    /// This function is called by LogExpert for every line that has to be drawn in the grid view. The faster your code
    /// handles the splitting, the faster LogExpert can draw the grid view content.
    /// </remarks>
    /// <param name="callback">Callback interface with functions which can be used by the columnizer</param>
    /// <param name="line">The line content to be splitted</param>
    public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
    {
      string[] cols = new string[2] { "", ""};

      // If the line is too short (i.e. does not follow the format for this columnizer) return the whole line content
      // in colum 1 (the log message column). Timestamp column will be left blank.
      if (line.Length < 23)
      {
        cols[1] = line;
        return cols;
      }

      try
      {
        DateTime dateTime = GetTimestamp(callback, line);
        string newDate = dateTime.ToString(DATETIME_FORMAT_OUT, this.cultureInfo);
        cols[0] = newDate;
      }
      catch (Exception)
      {
        cols[0] = "n/a";
      }
      int end = line.IndexOf(']');
      if (end != -1)
      {
        cols[1] = line.Substring(end + 1);    // rest of line
      }
      else
      {
        cols[1] = line;     // fail behaviour
      }
      return cols;
    }
Exemplo n.º 60
0
 public string[] SplitLine(ILogLineColumnizerCallback callback, string line)
 {
   return SplitCsvLine(line);
 }